Class: OrmAdapter::ActiveRecord
- Inherits:
-
Base
- Object
- Base
- OrmAdapter::ActiveRecord
show all
- Defined in:
- lib/orm_adapter/adapters/active_record.rb
Instance Attribute Summary
Attributes inherited from Base
#klass
Instance Method Summary
collapse
Methods inherited from Base
inherited, #initialize
Instance Method Details
#column_names ⇒ Object
Return list of column/property names
6
7
8
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 6
def column_names
klass.column_names
end
|
#create!(attributes = {}) ⇒ Object
33
34
35
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 33
def create!(attributes = {})
klass.create!(attributes)
end
|
#destroy(object) ⇒ Object
38
39
40
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 38
def destroy(object)
object.destroy && true if valid_object?(object)
end
|
#find_all(options = {}) ⇒ Object
27
28
29
30
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 27
def find_all(options = {})
conditions, order, limit, offset = (options)
klass.where(conditions_to_fields(conditions)).order(*order_clause(order)).limit(limit).offset(offset).all
end
|
#find_first(options = {}) ⇒ Object
21
22
23
24
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 21
def find_first(options = {})
conditions, order = (options)
klass.where(conditions_to_fields(conditions)).order(*order_clause(order)).first
end
|
#get(id) ⇒ Object
16
17
18
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 16
def get(id)
klass.where(klass.primary_key => wrap_key(id)).first
end
|
#get!(id) ⇒ Object
11
12
13
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 11
def get!(id)
klass.find(wrap_key(id))
end
|