Class: Dynamoid::Document::OrmAdapter
- Inherits:
-
OrmAdapter::Base
- Object
- OrmAdapter::Base
- Dynamoid::Document::OrmAdapter
- Defined in:
- lib/orm_adapter-dynamoid/dynamoid.rb
Instance Method Summary collapse
-
#column_names ⇒ Object
get a list of column names for a given class.
- #create!(attributes = {}) ⇒ Object
- #destroy(object) ⇒ Object
- #find_all(options = {}) ⇒ Object
- #find_first(options = {}) ⇒ Object
- #get(id) ⇒ Object
- #get!(id) ⇒ Object
Instance Method Details
#column_names ⇒ Object
get a list of column names for a given class
17 18 19 |
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 17 def column_names klass.attributes.keys end |
#create!(attributes = {}) ⇒ Object
46 47 48 |
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 46 def create!(attributes = {}) klass.create!(attributes) end |
#destroy(object) ⇒ Object
51 52 53 |
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 51 def destroy(object) object.destroy if valid_object?(object) end |
#find_all(options = {}) ⇒ Object
39 40 41 42 43 |
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 39 def find_all( = {}) conditions, order, limit, offset = extract_conditions!() # klass.where(conditions_to_fields(conditions)).order_by(order).limit(limit).offset(offset) klass.where(conditions_to_fields(conditions)) end |
#find_first(options = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 32 def find_first( = {}) conditions, order = extract_conditions!() # klass.limit(1).where(conditions_to_fields(conditions)).order_by(order).first klass.where(conditions_to_fields(conditions)).first end |
#get(id) ⇒ Object
27 28 29 |
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 27 def get(id) klass.where(klass.hash_key => wrap_key(id)).first end |