Module: Mitake::Model::Attributes Private
- Defined in:
- lib/mitake/model/attributes.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#assign_attributes(attributes = {}) ⇒ Object
private
Assign attribute by hash.
- #initialize(attributes = {}) ⇒ Object private
Instance Method Details
#assign_attributes(attributes = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Assign attribute by hash
19 20 21 22 23 24 25 26 27 |
# File 'lib/mitake/model/attributes.rb', line 19 def assign_attributes(attributes = {}) attributes.each do |key, value| next unless self.class.attribute_names.include?(key.to_s) next send("#{key}=", value) if respond_to?("#{key}=") type = self.class.attributes[key.to_s] instance_variable_set("@#{key}", self.class.cast(value, type)) end end |
#initialize(attributes = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/mitake/model/attributes.rb', line 10 def initialize(attributes = {}) assign_attributes(attributes) end |