Class: ActiveAny::Associations::CollectionProxy
- Inherits:
-
Relation
- Object
- Relation
- ActiveAny::Associations::CollectionProxy
show all
- Defined in:
- lib/active_any/associations/collection_proxy.rb
Constant Summary
Constants inherited
from Relation
Relation::CLAUSE_METHODS, Relation::MULTI_VALUE_METHODS, Relation::SINGLE_VALUE_METHODS, Relation::VALUE_METHODS
Instance Attribute Summary collapse
Attributes inherited from Relation
#klass, #loaded
Instance Method Summary
collapse
Methods inherited from Relation
create, #eager_loading?, #initialize_copy, #load, #loaded?, #merge, #merge!
#get_value, #group, #group!, #includes, #includes!, #limit, #limit!, #order, #order!, #reverse_order, #reverse_order!, #set_value, #values, #where, #where!
#find_by, #first, #last
Constructor Details
#initialize(klass, association) ⇒ CollectionProxy
Returns a new instance of CollectionProxy.
11
12
13
14
|
# File 'lib/active_any/associations/collection_proxy.rb', line 11
def initialize(klass, association)
@association = association
super(klass)
end
|
Instance Attribute Details
#association ⇒ Object
Returns the value of attribute association.
6
7
8
|
# File 'lib/active_any/associations/collection_proxy.rb', line 6
def association
@association
end
|
Instance Method Details
#==(other) ⇒ Object
25
26
27
|
# File 'lib/active_any/associations/collection_proxy.rb', line 25
def ==(other)
load_target == other
end
|
#proxy_association ⇒ Object
38
39
40
|
# File 'lib/active_any/associations/collection_proxy.rb', line 38
def proxy_association
@association
end
|
34
35
36
|
# File 'lib/active_any/associations/collection_proxy.rb', line 34
def records
load_target
end
|
48
49
50
51
|
# File 'lib/active_any/associations/collection_proxy.rb', line 48
def reload
proxy_association.reload
reset_scope
end
|
42
43
44
45
46
|
# File 'lib/active_any/associations/collection_proxy.rb', line 42
def reset
proxy_association.reset
proxy_association.reset_scope
reset_scope
end
|
#reset_scope ⇒ Object
53
54
55
56
57
|
# File 'lib/active_any/associations/collection_proxy.rb', line 53
def reset_scope @offsets = {}
@scope = nil
self
end
|
21
22
23
|
# File 'lib/active_any/associations/collection_proxy.rb', line 21
def scope
@scope ||= @association.scope
end
|
#take(limit = nil) ⇒ Object
16
17
18
19
|
# File 'lib/active_any/associations/collection_proxy.rb', line 16
def take(limit = nil)
load_target if find_from_target?
super
end
|
#to_ary ⇒ Object
Also known as:
to_a
29
30
31
|
# File 'lib/active_any/associations/collection_proxy.rb', line 29
def to_ary
load_target.dup
end
|