Class: Dock::Couchbase
- Inherits:
-
Base
- Object
- Base
- Dock::Couchbase
show all
- Defined in:
- lib/dock/adapters/couchbase.rb
Instance Attribute Summary
Attributes inherited from Base
#model
Instance Method Summary
collapse
Methods inherited from Base
#embedded, inherited, #initialize, #scoped
Constructor Details
This class inherits a constructor from Dock::Base
Instance Method Details
#all(options = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/dock/adapters/couchbase.rb', line 14
def all(options = {})
view_name, view_options, options = view_for_options(options)
conditions, order, limit, offset = (options)
stream = model.send(view_name, view_options)
stream = apply_conditions(stream, conditions)
stream = apply_order(stream, order)
stream = stream.drop(offset) if offset
stream = stream.take(limit) if limit
stream.to_a end
|
#associations ⇒ Object
45
46
47
|
# File 'lib/dock/adapters/couchbase.rb', line 45
def associations()
end
|
#belongs_to ⇒ Object
61
62
63
|
# File 'lib/dock/adapters/couchbase.rb', line 61
def belongs_to()
end
|
#column_names ⇒ Object
51
52
53
|
# File 'lib/dock/adapters/couchbase.rb', line 51
def column_names()
model.properties.map(&:name)
end
|
#count(options = {}) ⇒ Object
55
56
57
|
# File 'lib/dock/adapters/couchbase.rb', line 55
def count(options = {})
all(options).count
end
|
#create(attributes = {}) ⇒ Object
5
6
7
|
# File 'lib/dock/adapters/couchbase.rb', line 5
def create(attributes = {})
model.create!(attributes)
end
|
#cyclic? ⇒ Boolean
73
74
75
|
# File 'lib/dock/adapters/couchbase.rb', line 73
def cyclic?
false
end
|
#destroy(object) ⇒ Object
42
43
44
|
# File 'lib/dock/adapters/couchbase.rb', line 42
def destroy(object)
object.destroy if valid_object?(object)
end
|
#embedded? ⇒ Boolean
70
71
72
|
# File 'lib/dock/adapters/couchbase.rb', line 70
def embedded?
false
end
|
#encoding ⇒ Object
58
59
60
|
# File 'lib/dock/adapters/couchbase.rb', line 58
def encoding
'UTF-8'
end
|
#find(id) ⇒ Object
8
9
10
|
# File 'lib/dock/adapters/couchbase.rb', line 8
def find(id)
model.find wrap_key(id)
end
|
#find!(id) ⇒ Object
11
12
13
|
# File 'lib/dock/adapters/couchbase.rb', line 11
def find!(id)
model.find_by_id(wrap_key(id))
end
|
#first(options = {}) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/dock/adapters/couchbase.rb', line 25
def first(options = {})
id = options.delete(:id)
conditions, _ = (options.dup)
if id
apply_conditions([get(id)], conditions).first
else
find_all(options).first
end
end
|
#has_many ⇒ Object
64
65
66
|
# File 'lib/dock/adapters/couchbase.rb', line 64
def has_many()
end
|
#id ⇒ Object
34
35
36
|
# File 'lib/dock/adapters/couchbase.rb', line 34
def id
model.id
end
|
#model_name ⇒ Object
48
49
50
|
# File 'lib/dock/adapters/couchbase.rb', line 48
def model_name()
model.class.name
end
|
#properties ⇒ Object
79
80
81
|
# File 'lib/dock/adapters/couchbase.rb', line 79
def properties()
end
|
#scoped? ⇒ Boolean
67
68
69
|
# File 'lib/dock/adapters/couchbase.rb', line 67
def scoped?
false
end
|
#supports_joins? ⇒ Boolean
76
77
78
|
# File 'lib/dock/adapters/couchbase.rb', line 76
def supports_joins?
false
end
|
#update(search_key = :id, find_by, update_key, by_value) ⇒ Object
37
38
39
40
41
|
# File 'lib/dock/adapters/couchbase.rb', line 37
def update(search_key=:id, find_by, update_key, by_value)
entry = model.find(find_by)
entry.update(update_key => by_value)
entry.save
end
|