Class: Ambition::Context
Instance Attribute Summary collapse
-
#clauses ⇒ Object
readonly
These are the methods your Query and Translator classes will want to access.
-
#owner ⇒ Object
readonly
These are the methods your Query and Translator classes will want to access.
-
#stash ⇒ Object
readonly
These are the methods your Query and Translator classes will want to access.
Instance Method Summary
collapse
Methods included from API
#all?, #ambition_adapter, #ambition_adapter=, #ambition_owner, #any?, #detect, #each, #empty?, #entries, #first, #select, #slice, #sort_by
Constructor Details
#initialize(owner) ⇒ Context
Returns a new instance of Context.
21
22
23
24
25
|
# File 'lib/ambition/context.rb', line 21
def initialize(owner)
@owner = owner
@clauses = {}
@stash = {}
end
|
Instance Attribute Details
These are the methods your Query and Translator classes will want to access.
+owner+ The class everything was called on. Like `User'
+clauses+ A hash of arrays, one key per processor.
So, if someone called User.select, your
+clauses+ hash would have a :select key with
an array of translated strings via your Select
class.
+stash+ A place for you to stick stuff. Available to
all Translators and your Query class.
19
20
21
|
# File 'lib/ambition/context.rb', line 19
def clauses
@clauses
end
|
These are the methods your Query and Translator classes will want to access.
+owner+ The class everything was called on. Like `User'
+clauses+ A hash of arrays, one key per processor.
So, if someone called User.select, your
+clauses+ hash would have a :select key with
an array of translated strings via your Select
class.
+stash+ A place for you to stick stuff. Available to
all Translators and your Query class.
19
20
21
|
# File 'lib/ambition/context.rb', line 19
def owner
@owner
end
|
These are the methods your Query and Translator classes will want to access.
+owner+ The class everything was called on. Like `User'
+clauses+ A hash of arrays, one key per processor.
So, if someone called User.select, your
+clauses+ hash would have a :select key with
an array of translated strings via your Select
class.
+stash+ A place for you to stick stuff. Available to
all Translators and your Query class.
19
20
21
|
# File 'lib/ambition/context.rb', line 19
def stash
@stash
end
|
Instance Method Details
#<<(clause) ⇒ Object
31
32
33
34
35
|
# File 'lib/ambition/context.rb', line 31
def <<(clause)
@clauses[clause.key] ||= []
@clauses[clause.key] << clause.to_s
self
end
|
#ambition_context ⇒ Object
27
28
29
|
# File 'lib/ambition/context.rb', line 27
def ambition_context
self
end
|
58
59
60
|
# File 'lib/ambition/context.rb', line 58
def inspect
"(Query object: call #to_s or #to_hash to inspect, call an Enumerable (such as #each or #first) to request data)"
end
|
49
50
51
|
# File 'lib/ambition/context.rb', line 49
def kick
adapter_query.kick
end
|
#size ⇒ Object
Also known as:
length
53
54
55
|
# File 'lib/ambition/context.rb', line 53
def size
adapter_query.size
end
|
41
42
43
|
# File 'lib/ambition/context.rb', line 41
def to_hash
adapter_query.to_hash
end
|
45
46
47
|
# File 'lib/ambition/context.rb', line 45
def to_s
adapter_query.to_s
end
|