Class: Dock::ActiveRecord
- Defined in:
- lib/dock/adapters/active_record.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Checked.
- #associations ⇒ Object
- #belongs_to ⇒ Object
-
#column_names ⇒ Object
Checked.
-
#count(options = {}) ⇒ Object
Checked.
-
#create(attributes = {}) ⇒ Object
Checked.
-
#cyclic? ⇒ Boolean
Checked.
-
#destroy(object) ⇒ Object
Checked.
-
#embedded? ⇒ Boolean
Checked.
-
#encoding ⇒ Object
Checked.
-
#find(id) ⇒ Object
Checked.
-
#find!(id) ⇒ Object
Checked.
-
#first(options = {}) ⇒ Object
Checked.
- #has_many ⇒ Object
-
#id ⇒ Object
Checked.
-
#model_name ⇒ Object
Checked.
- #order_clause(order) ⇒ Object
- #properties ⇒ Object
-
#scoped? ⇒ Boolean
Checked.
-
#supports_joins? ⇒ Boolean
Checked.
-
#update(search_key, find_by, update_key, by_value) ⇒ Object
Checked.
Methods inherited from Base
#embedded, inherited, #initialize, #scoped
Constructor Details
This class inherits a constructor from Dock::Base
Instance Method Details
#all(options = {}) ⇒ Object
Checked
18 19 20 |
# File 'lib/dock/adapters/active_record.rb', line 18 def all( = {}) construct_relation(model, ) end |
#associations ⇒ Object
38 39 40 |
# File 'lib/dock/adapters/active_record.rb', line 38 def associations() end |
#belongs_to ⇒ Object
57 58 59 |
# File 'lib/dock/adapters/active_record.rb', line 57 def belongs_to() end |
#column_names ⇒ Object
Checked
46 47 48 |
# File 'lib/dock/adapters/active_record.rb', line 46 def column_names model.column_names end |
#count(options = {}) ⇒ Object
Checked
50 51 52 |
# File 'lib/dock/adapters/active_record.rb', line 50 def count( = {}) all().count end |
#create(attributes = {}) ⇒ Object
Checked
6 7 8 |
# File 'lib/dock/adapters/active_record.rb', line 6 def create(attributes = {}) model.create!(attributes) end |
#cyclic? ⇒ Boolean
Checked
72 73 74 |
# File 'lib/dock/adapters/active_record.rb', line 72 def cyclic? false end |
#destroy(object) ⇒ Object
Checked
35 36 37 |
# File 'lib/dock/adapters/active_record.rb', line 35 def destroy(object) object.destroy && true if valid_object?(object) end |
#embedded? ⇒ Boolean
Checked
68 69 70 |
# File 'lib/dock/adapters/active_record.rb', line 68 def false end |
#encoding ⇒ Object
Checked
54 55 56 |
# File 'lib/dock/adapters/active_record.rb', line 54 def encoding model.client_encoding() end |
#find(id) ⇒ Object
Checked
10 11 12 |
# File 'lib/dock/adapters/active_record.rb', line 10 def find(id) model.find(wrap_key(id)) end |
#find!(id) ⇒ Object
Checked
14 15 16 |
# File 'lib/dock/adapters/active_record.rb', line 14 def find!(id) model.where(model.primary_key => wrap_key(id)).first end |
#first(options = {}) ⇒ Object
Checked
22 23 24 |
# File 'lib/dock/adapters/active_record.rb', line 22 def first( = {}) construct_relation(model, ).first end |
#has_many ⇒ Object
60 61 62 |
# File 'lib/dock/adapters/active_record.rb', line 60 def has_many() end |
#id ⇒ Object
Checked
26 27 28 |
# File 'lib/dock/adapters/active_record.rb', line 26 def id model.id end |
#model_name ⇒ Object
Checked
42 43 44 |
# File 'lib/dock/adapters/active_record.rb', line 42 def model_name model.model_name end |
#order_clause(order) ⇒ Object
112 113 114 |
# File 'lib/dock/adapters/active_record.rb', line 112 def order_clause(order) order.map {|pair| "#{pair[0]} #{pair[1]}"}.join(",") end |
#properties ⇒ Object
79 80 81 |
# File 'lib/dock/adapters/active_record.rb', line 79 def properties() end |
#scoped? ⇒ Boolean
Checked
64 65 66 |
# File 'lib/dock/adapters/active_record.rb', line 64 def scoped? model.all end |
#supports_joins? ⇒ Boolean
Checked
76 77 78 |
# File 'lib/dock/adapters/active_record.rb', line 76 def supports_joins? true end |
#update(search_key, find_by, update_key, by_value) ⇒ Object
Checked
30 31 32 33 |
# File 'lib/dock/adapters/active_record.rb', line 30 def update(search_key, find_by, update_key, by_value) entry = model.find_by(search_key find_by) entry.update(update_key by_value) end |