Method: LogicalModel::Attributes::InstanceMethods#attributes

Defined in:
lib/logical_model/attributes.rb

#attributesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/logical_model/attributes.rb', line 15

def attributes
  attrs = self.class.attribute_keys.inject(ActiveSupport::HashWithIndifferentAccess.new) do |result,key|
    result[key] = read_attribute_for_validation(key)
    result
  end

  unless self.class.has_many_keys.blank?
    self.class.has_many_keys.inject(attrs) do |result,key|
      result["#{key}_attributes"] = send(key).map {|a| a.attributes}
      result
    end
  end
  attrs.reject {|key, value| key == "_id" && value.blank?}
end