Method: Facebooker::Model#populate_from_hash!
- Defined in:
- lib/facebooker/model.rb
#populate_from_hash!(hash) ⇒ Object
Set model’s attributes via Hash. Keys should map directly to the model’s attribute names.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/facebooker/model.rb', line 123 def populate_from_hash!(hash) unless hash.nil? || hash.empty? hash.each do |key, value| set_attr_method = "#{key}=" unless value.nil? if respond_to?(set_attr_method) self.__send__(set_attr_method, value) else Facebooker::Logging.log_info("**Warning**, Attempt to set non-attribute: #{key}",hash) end end end @populated = true end end |