module LogicalModel::Attributes::InstanceMethods
Public Instance Methods
attributes()
click to toggle source
# 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
attributes=(attrs)
click to toggle source
# File lib/logical_model/attributes.rb, line 11 def attributes=(attrs) attrs.each{|k,v| send("#{k}=",v) if respond_to?("#{k}=")} end