Module: Her::Model::Attributes::ClassMethods
- Defined in:
- lib/her/model/attributes.rb
Instance Method Summary collapse
-
#attributes(*attributes) ⇒ Object
Define the attributes that will be used to track dirty attributes and validations.
-
#store_metadata(value = nil) ⇒ Object
Define the accessor in which the API response metadata (obtained from the parsing middleware) will be stored.
-
#store_response_errors(value = nil) ⇒ Object
Define the accessor in which the API response errors (obtained from the parsing middleware) will be stored.
Instance Method Details
#attributes(*attributes) ⇒ Object
Define the attributes that will be used to track dirty attributes and validations
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/her/model/attributes.rb', line 187 def attributes(*attributes) define_attribute_methods attributes attributes.each do |attribute| attribute = attribute.to_sym unless instance_methods.include?(:"#{attribute}=") define_method("#{attribute}=") do |value| @attributes[:"#{attribute}"] = nil unless @attributes.include?(:"#{attribute}") self.send(:"#{attribute}_will_change!") if @attributes[:'#{attribute}'] != value @attributes[:"#{attribute}"] = value end end unless instance_methods.include?(:"#{attribute}?") define_method("#{attribute}?") do @attributes.include?(:"#{attribute}") && @attributes[:"#{attribute}"].present? end end end end |
#store_metadata(value = nil) ⇒ Object
Define the accessor in which the API response metadata (obtained from the parsing middleware) will be stored
231 232 233 |
# File 'lib/her/model/attributes.rb', line 231 def (value = nil) store_her_data(:metadata, value) end |
#store_response_errors(value = nil) ⇒ Object
Define the accessor in which the API response errors (obtained from the parsing middleware) will be stored
218 219 220 |
# File 'lib/her/model/attributes.rb', line 218 def store_response_errors(value = nil) store_her_data(:response_errors, value) end |