Skip to content

Commit

Permalink
Merge pull request #5977 from oscardelben/refactor_serializable_hash
Browse files Browse the repository at this point in the history
Minor refactor of serializable hash
  • Loading branch information
josevalim committed Apr 25, 2012
2 parents 2aabf8c + a631dd9 commit 217e9c0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions activemodel/lib/active_model/serialization.rb
Expand Up @@ -78,8 +78,7 @@ def serializable_hash(options = nil)
hash = {} hash = {}
attribute_names.each { |n| hash[n] = read_attribute_for_serialization(n) } attribute_names.each { |n| hash[n] = read_attribute_for_serialization(n) }


method_names = Array(options[:methods]).select { |n| respond_to?(n) } Array(options[:methods]).each { |m| hash[m.to_s] = send(m) if respond_to?(m) }
method_names.each { |n| hash[n.to_s] = send(n) }


serializable_add_includes(options) do |association, records, opts| serializable_add_includes(options) do |association, records, opts|
hash[association.to_s] = if records.is_a?(Enumerable) hash[association.to_s] = if records.is_a?(Enumerable)
Expand Down

0 comments on commit 217e9c0

Please sign in to comment.