Skip to content

Commit

Permalink
Merge pull request #278 from RKushnir/patch-1
Browse files Browse the repository at this point in the history
Allow Message#each_field to return an enumerator
  • Loading branch information
abrandoned committed Feb 1, 2016
2 parents d8fce01 + c332f18 commit bd40135
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/protobuf/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def dup
# Iterate over every field, invoking the given block
#
def each_field
return to_enum(:each_field) unless block_given?

self.class.all_fields.each do |field|
value = __send__(field.getter)
yield(field, value)
Expand Down

0 comments on commit bd40135

Please sign in to comment.