Class: Peictt::DatabaseMapper
- Extended by:
- Orm::QueryHelpers
- Defined in:
- lib/peictt/orm/database_mapper.rb
Class Attribute Summary collapse
-
.table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(model, action = :create) ⇒ DatabaseMapper
constructor
A new instance of DatabaseMapper.
- #save ⇒ Object
Methods included from Orm::QueryHelpers
destroy, destroy_all, destroy_all_query, destroy_query, find_by, find_query, get_all, get_values_for_instance, set_columns_for_instance
Constructor Details
#initialize(model, action = :create) ⇒ DatabaseMapper
Returns a new instance of DatabaseMapper.
9 10 11 12 13 14 15 16 17 |
# File 'lib/peictt/orm/database_mapper.rb', line 9 def initialize(model, action = :create) self.class.table = model.class.to_s.downcase.pluralize @model = model @action = action @variables = model.instance_variables set_columns_and_values if create? self end |
Class Attribute Details
.table ⇒ Object
Returns the value of attribute table.
6 7 8 |
# File 'lib/peictt/orm/database_mapper.rb', line 6 def table @table end |
Instance Method Details
#save ⇒ Object
19 20 21 22 |
# File 'lib/peictt/orm/database_mapper.rb', line 19 def save Database.execute_query query, @values true end |