Class: Mongoid::Document::OrmAdapter
Instance Attribute Summary
#klass
Instance Method Summary
collapse
inherited, #initialize
Instance Method Details
#column_names ⇒ Object
get a list of column names for a given class
11
12
13
|
# File 'lib/orm_adapter/adapters/mongoid.rb', line 11
def column_names
klass.fields.keys
end
|
#create!(attributes = {}) ⇒ Object
38
39
40
|
# File 'lib/orm_adapter/adapters/mongoid.rb', line 38
def create!(attributes = {})
klass.create!(attributes)
end
|
#destroy(object) ⇒ Object
43
44
45
|
# File 'lib/orm_adapter/adapters/mongoid.rb', line 43
def destroy(object)
object.destroy if valid_object?(object)
end
|
#find_all(options = {}) ⇒ Object
32
33
34
35
|
# File 'lib/orm_adapter/adapters/mongoid.rb', line 32
def find_all(options = {})
conditions, order, limit, offset = (options)
klass.where(conditions_to_fields(conditions)).order_by(order).limit(limit).offset(offset)
end
|
#find_first(options = {}) ⇒ Object
26
27
28
29
|
# File 'lib/orm_adapter/adapters/mongoid.rb', line 26
def find_first(options = {})
conditions, order = (options)
klass.limit(1).where(conditions_to_fields(conditions)).order_by(order).first
end
|
#get(id) ⇒ Object
21
22
23
|
# File 'lib/orm_adapter/adapters/mongoid.rb', line 21
def get(id)
klass.where(:_id => wrap_key(id)).first
end
|
#get!(id) ⇒ Object
16
17
18
|
# File 'lib/orm_adapter/adapters/mongoid.rb', line 16
def get!(id)
klass.find(wrap_key(id))
end
|