Class: Dock::Mongoid
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.
- #properties ⇒ Object
-
#scoped? ⇒ Boolean
Checked.
-
#supports_joins ⇒ Object
Checked.
-
#update(search_key, find_by, update_key, by_value) ⇒ Object
Checked.
Methods inherited from Base
#embedded, inherited, #initialize, #scoped, #supports_joins?
Constructor Details
This class inherits a constructor from Dock::Base
Instance Method Details
#all(options = {}) ⇒ Object
Checked
18 19 20 21 |
# File 'lib/dock/adapters/mongoid.rb', line 18 def all( = {}) conditions, order, limit, offset = extract_conditions!() model.where(conditions_to_fields(conditions)).order_by(order).limit(limit).offset(offset) end |
#associations ⇒ Object
40 41 42 |
# File 'lib/dock/adapters/mongoid.rb', line 40 def associations() end |
#belongs_to ⇒ Object
59 60 61 |
# File 'lib/dock/adapters/mongoid.rb', line 59 def belongs_to() end |
#column_names ⇒ Object
Checked
48 49 50 |
# File 'lib/dock/adapters/mongoid.rb', line 48 def column_names model.fields.keys end |
#count(options = {}) ⇒ Object
Checked
52 53 54 |
# File 'lib/dock/adapters/mongoid.rb', line 52 def count( = {}) all().count end |
#create(attributes = {}) ⇒ Object
Checked
6 7 8 |
# File 'lib/dock/adapters/mongoid.rb', line 6 def create(attributes = {}) model.create!(attributes) end |
#cyclic? ⇒ Boolean
Checked
74 75 76 |
# File 'lib/dock/adapters/mongoid.rb', line 74 def cyclic? model.cyclic? end |
#destroy(object) ⇒ Object
Checked
37 38 39 |
# File 'lib/dock/adapters/mongoid.rb', line 37 def destroy(object) object.destroy if valid_object?(object) end |
#embedded? ⇒ Boolean
Checked
70 71 72 |
# File 'lib/dock/adapters/mongoid.rb', line 70 def model.relations.values.detect { |a| a.macro.to_sym == :embedded_in } end |
#encoding ⇒ Object
Checked
56 57 58 |
# File 'lib/dock/adapters/mongoid.rb', line 56 def encoding 'UTF-8' end |
#find(id) ⇒ Object
Checked
10 11 12 |
# File 'lib/dock/adapters/mongoid.rb', line 10 def find(id) model.find(wrap_key(id)) end |
#find!(id) ⇒ Object
Checked
14 15 16 |
# File 'lib/dock/adapters/mongoid.rb', line 14 def find!(id) model.where(:_id => wrap_key(id)).first end |
#first(options = {}) ⇒ Object
Checked
23 24 25 26 |
# File 'lib/dock/adapters/mongoid.rb', line 23 def first( = {}) conditions, order = extract_conditions!() model.limit(1).where(conditions_to_fields(conditions)).order_by(order).first end |
#has_many ⇒ Object
62 63 64 |
# File 'lib/dock/adapters/mongoid.rb', line 62 def has_many() end |
#id ⇒ Object
Checked
28 29 30 |
# File 'lib/dock/adapters/mongoid.rb', line 28 def id '_id' end |
#model_name ⇒ Object
Checked
44 45 46 |
# File 'lib/dock/adapters/mongoid.rb', line 44 def model_name model.class.name end |
#properties ⇒ Object
81 82 83 |
# File 'lib/dock/adapters/mongoid.rb', line 81 def properties() end |
#scoped? ⇒ Boolean
Checked
66 67 68 |
# File 'lib/dock/adapters/mongoid.rb', line 66 def scoped? model.scoped end |
#supports_joins ⇒ Object
Checked
78 79 80 |
# File 'lib/dock/adapters/mongoid.rb', line 78 def supports_joins false end |
#update(search_key, find_by, update_key, by_value) ⇒ Object
Checked
32 33 34 35 |
# File 'lib/dock/adapters/mongoid.rb', line 32 def update(search_key, find_by, update_key, by_value) entry = model.where(search_key, find_by) entry.update_attributes!(update_key, by_value) end |