Method: CollectionJSON::Attribute#to_hash

Defined in:
lib/collection-json/attribute.rb

#to_hashObject



44
45
46
47
48
49
50
51
52
# File 'lib/collection-json/attribute.rb', line 44

def to_hash
  hash = Hash.new.tap do |item|
    self.class.nested_attributes.each do |attribute|
      value = send(attribute)
      item[attribute] = value unless skip_value?(value)
    end
  end
  self.class.root_node ? {self.class.root_node => hash} : hash
end