Class: OrmAdapter::ActiveRecord

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from OrmAdapter::Base

Instance Method Details

#column_namesObject

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

See Also:



31
32
33
# File 'lib/orm_adapter/adapters/active_record.rb', line 31

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

#destroy(object) ⇒ Object

See Also:



36
37
38
# File 'lib/orm_adapter/adapters/active_record.rb', line 36

def destroy(object)
  object.destroy && true if valid_object?(object)
end

#find_all(options = {}) ⇒ Object

See Also:



26
27
28
# File 'lib/orm_adapter/adapters/active_record.rb', line 26

def find_all(options = {})
  construct_relation(klass, options)
end

#find_first(options = {}) ⇒ Object

See Also:



21
22
23
# File 'lib/orm_adapter/adapters/active_record.rb', line 21

def find_first(options = {})
  construct_relation(klass, options).first
end

#get(id) ⇒ Object

See Also:



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

See Also:



11
12
13
# File 'lib/orm_adapter/adapters/active_record.rb', line 11

def get!(id)
  klass.find(wrap_key(id))
end