Skip to content

Commit

Permalink
Merge pull request #5 from codekitchen/master
Browse files Browse the repository at this point in the history
merge codekitchen head
  • Loading branch information
bufdev committed Aug 22, 2013
2 parents fa61b55 + 8075d50 commit 16914ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/protocol_buffers/runtime/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def value_to_names_map
# values do not have to be unique
value = self.const_get(constant)
hash[value] ||= Array.new
hash[value] << constant
hash[value] << constant.to_sym
hash
end
@value_to_names_map
end

def name_to_value_map
@name_to_value_map ||= self.constants.inject(Hash.new) do |hash, constant|
hash[constant] = self.const_get(constant)
hash[constant.to_sym] = self.const_get(constant)
hash
end
@name_to_value_map
Expand Down
8 changes: 4 additions & 4 deletions spec/runtime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,10 @@ class IntMsg < ProtocolBuffers::Message
end

it "has only Enum values as constants" do
Enums::FooEnum.constants.should =~ [:ONE, :TWO, :THREE]
Enums::BarEnum.constants.should =~ [:FOUR, :FIVE, :SIX]
Enums::FooMessage::NestedFooEnum.constants.should =~ [:SEVEN, :EIGHT]
Enums::FooMessage::NestedBarEnum.constants.should =~ [:NINE, :TEN]
Enums::FooEnum.constants.map(&:to_sym).should =~ [:ONE, :TWO, :THREE]
Enums::BarEnum.constants.map(&:to_sym).should =~ [:FOUR, :FIVE, :SIX]
Enums::FooMessage::NestedFooEnum.constants.map(&:to_sym).should =~ [:SEVEN, :EIGHT]
Enums::FooMessage::NestedBarEnum.constants.map(&:to_sym).should =~ [:NINE, :TEN]
end

it "correctly populates the maps between name and values for Enums" do
Expand Down

0 comments on commit 16914ab

Please sign in to comment.