Method: Essential::Resource#init_from

Defined in:
lib/essential/resource.rb

#init_from(attributes) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/essential/resource.rb', line 58

def init_from(attributes)
  attributes = (attributes || {}).clone

  # reject reject keys that aren't actually our attrs
  @attributes = filter_attrs(attributes)

  if self.class.schema
    self.class.schema.each do |key,type|
      apply_schema(key, type)
    end
  end
  self
end