Class: Almicube::Selector::HasManySelector
- Inherits:
-
Base
- Object
- Base
- Almicube::Selector::HasManySelector
show all
- Defined in:
- lib/almicube/selector/has_many_selector.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#class_name
Attributes included from Cog
#ranking
Instance Method Summary
collapse
Methods inherited from Base
#data_provider?
Methods included from Cog
#active?, #after_aggregate
Constructor Details
Returns a new instance of HasManySelector.
7
8
9
10
11
12
|
# File 'lib/almicube/selector/has_many_selector.rb', line 7
def initialize(options={})
super(options)
@target = options[:target]
@association_name = options[:association_name]
end
|
Instance Attribute Details
#association_name ⇒ Object
Returns the value of attribute association_name.
5
6
7
|
# File 'lib/almicube/selector/has_many_selector.rb', line 5
def association_name
@association_name
end
|
#target ⇒ Object
Returns the value of attribute target.
5
6
7
|
# File 'lib/almicube/selector/has_many_selector.rb', line 5
def target
@target
end
|
Instance Method Details
#before_aggregate ⇒ Object
22
23
24
25
26
|
# File 'lib/almicube/selector/has_many_selector.rb', line 22
def before_aggregate
records.map{ |r| r.to_param }.each do |i|
Config.config.connection.zadd(interstore_key, 0, i)
end
end
|
#interstore ⇒ Object
28
29
30
|
# File 'lib/almicube/selector/has_many_selector.rb', line 28
def interstore
interstore_key
end
|
#label ⇒ Object
18
19
20
|
# File 'lib/almicube/selector/has_many_selector.rb', line 18
def label
"#{target.class.to_s.underscore}-#{target.to_param}"
end
|
#records ⇒ Object
14
15
16
|
# File 'lib/almicube/selector/has_many_selector.rb', line 14
def records
target.send(association_name)
end
|