Class: Dynamoid::Document::OrmAdapter

Inherits:
OrmAdapter::Base
  • Object
show all
Defined in:
lib/orm_adapter-dynamoid/dynamoid.rb

Instance Method Summary collapse

Instance Method Details

#column_namesObject

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

See Also:

  • OrmAdapter::Base#create!


46
47
48
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 46

def create!(attributes = {})
  klass.create!(attributes)
end

#destroy(object) ⇒ Object

See Also:

  • OrmAdapter::Base#destroy


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

See Also:

  • OrmAdapter::Base#find_all


39
40
41
42
43
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 39

def find_all(options = {})
  conditions, order, limit, offset = extract_conditions!(options)
#        klass.where(conditions_to_fields(conditions)).order_by(order).limit(limit).offset(offset)
  klass.where(conditions_to_fields(conditions))
end

#find_first(options = {}) ⇒ Object

See Also:

  • OrmAdapter::Base#find_first


32
33
34
35
36
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 32

def find_first(options = {})
  conditions, order = extract_conditions!(options)
#        klass.limit(1).where(conditions_to_fields(conditions)).order_by(order).first
  klass.where(conditions_to_fields(conditions)).first
end

#get(id) ⇒ Object

See Also:

  • OrmAdapter::Base#get


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

#get!(id) ⇒ Object

See Also:

  • OrmAdapter::Base#get!


22
23
24
# File 'lib/orm_adapter-dynamoid/dynamoid.rb', line 22

def get!(id)
  klass.find_by_id(wrap_key(id)) || raise(Dynamoid::Document::DocumentNotFound)
end