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
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
inherited, #initialize
Class Method Details
.except_classes ⇒ Object
Do not consider these to be part of the class list
6
7
8
9
10
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 6
def self.except_classes
@@except_classes ||= [
"ActiveRecord::SessionStore::Session"
]
end
|
.model_classes ⇒ Object
Gets a list of the available models for this adapter
13
14
15
16
17
18
19
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 13
def self.model_classes
klasses = ::ActiveRecord::Base.__send__(:descendants)
klasses.select do |klass|
!klass.abstract_class? && !except_classes.include?(klass.name)
end
end
|
Instance Method Details
#column_names ⇒ Object
Return list of column/property names
22
23
24
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 22
def column_names
klass.column_names
end
|
#create!(attributes = {}) ⇒ Object
49
50
51
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 49
def create!(attributes = {})
klass.create!(attributes)
end
|
#destroy(object) ⇒ Object
54
55
56
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 54
def destroy(object)
object.destroy && true if valid_object?(object)
end
|
#find_all(options = {}) ⇒ Object
43
44
45
46
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 43
def find_all(options = {})
conditions, order = extract_conditions_and_order!(options)
klass.where(conditions_to_fields(conditions)).order(*order_clause(order)).all
end
|
#find_first(options = {}) ⇒ Object
37
38
39
40
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 37
def find_first(options = {})
conditions, order = extract_conditions_and_order!(options)
klass.where(conditions_to_fields(conditions)).order(*order_clause(order)).first
end
|
#get(id) ⇒ Object
32
33
34
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 32
def get(id)
klass.where(klass.primary_key => wrap_key(id)).first
end
|
#get!(id) ⇒ Object
27
28
29
|
# File 'lib/orm_adapter/adapters/active_record.rb', line 27
def get!(id)
klass.find(wrap_key(id))
end
|