Skip to content

Commit

Permalink
pbarray methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatunov Serheo committed Mar 20, 2014
1 parent 71105a3 commit fcc7034
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 131 deletions.
18 changes: 9 additions & 9 deletions Example/Person.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 34 additions & 34 deletions Example/Person.pb.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Example/Web/person.pb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# message Person {
# required string name = 1;
# required int32 personId = 2;
# required int32 personId = 2;
# optional string email = 3;
#
# enum PhoneType {
Expand All @@ -17,7 +17,7 @@
# optional PhoneType type = 2 [default = HOME];
# }
#
# repeated PhoneNumber phone = 4;
# repeated PhoneNumber phones = 4;
# }

require 'protobuf/message/message'
Expand All @@ -41,5 +41,5 @@ class PhoneNumber < ::Protobuf::Message
required :string, :number, 1
optional :PhoneType, :type, 2, :default => :HOME
end
repeated :PhoneNumber, :phone, 4
repeated :PhoneNumber, :phones, 4
end
40 changes: 20 additions & 20 deletions Example/Web/sinatra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
PHONE_COUNT = 1000

get '/1/getGroups' do
content_type 'application/octet-stream'
n = Person::PhoneNumber.new(:number => "number", :type => Person::PhoneType::MOBILE)
p = Person.new(:personId => 123, :name => "name", :email => 'email@mail.aa')
p.phone << n
content_type 'application/octet-stream'
n = Person::PhoneNumber.new(:number => "number", :type => Person::PhoneType::MOBILE)
p = Person.new(:personId => 123, :name => "name", :email => 'email@mail.aa')
p.phones << n

result = Array.new
PHONE_COUNT.times do |x|
n = Person::PhoneNumber.new(:number => "number" + x.to_s, :type => Person::PhoneType::MOBILE)
p.phone << n
end
p.serialize_to_string
result = Array.new
PHONE_COUNT.times do |x|
n = Person::PhoneNumber.new(:number => "number" + x.to_s, :type => Person::PhoneType::MOBILE)
p.phones << n
end
p.serialize_to_string
end

get '/1/getGroupsJson' do
content_type 'application/json'
content_type 'application/json'

list = Array.new
list << {:number => "number", :type => 0}
p = {:personId => 123, :name => "name", :email => 'email@mail.aa'}
PHONE_COUNT.times do |x|
list << {:number => "number" + x.to_s, :type => 0}
end
p[:phone] = list
p.to_json
list = Array.new
list << {:number => "number", :type => 0}
p = {:personId => 123, :name => "name", :email => 'email@mail.aa'}

PHONE_COUNT.times do |x|
list << {:number => "number" + x.to_s, :type => 0}
end
p[:phones] = list
p.to_json
end
Loading

0 comments on commit fcc7034

Please sign in to comment.