Module: GdatastoreMapper::Base::ClassMethods
- Defined in:
- lib/gdatastore_mapper/base.rb
Instance Method Summary collapse
- #attr_accessor(*vars) ⇒ Object
- #attributes ⇒ Object
- #create(params) ⇒ Object
- #from_entity(entity) ⇒ Object
Instance Method Details
#attr_accessor(*vars) ⇒ Object
25 26 27 28 29 |
# File 'lib/gdatastore_mapper/base.rb', line 25 def attr_accessor(*vars) @attributes ||= [] @attributes.concat vars super end |
#attributes ⇒ Object
31 32 33 34 35 |
# File 'lib/gdatastore_mapper/base.rb', line 31 def attributes @attributes.reject do |attr| [:id, :created_at, :updated_at].include? attr end end |
#create(params) ⇒ Object
46 47 48 49 50 |
# File 'lib/gdatastore_mapper/base.rb', line 46 def create params record = self.new params record.save record end |
#from_entity(entity) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/gdatastore_mapper/base.rb', line 37 def from_entity entity record = self.new record.id = entity.key.id entity.properties.to_hash.each do |name, value| record.send "#{name}=", value if record.respond_to? "#{name}=" end record end |