Class: Almicube::Selector::HasManySelector
- Defined in:
- lib/almicube/selector/has_many_selector.rb
Instance Attribute Summary collapse
-
#association_name ⇒ Object
readonly
Returns the value of attribute association_name.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Attributes inherited from Base
Attributes included from Cog
Instance Method Summary collapse
- #before_aggregate ⇒ Object
-
#initialize(options = {}) ⇒ HasManySelector
constructor
A new instance of HasManySelector.
- #interstore ⇒ Object
- #label ⇒ Object
- #records ⇒ Object
Methods inherited from Base
Methods included from Cog
Constructor Details
#initialize(options = {}) ⇒ HasManySelector
Returns a new instance of HasManySelector.
7 8 9 10 11 12 |
# File 'lib/almicube/selector/has_many_selector.rb', line 7 def initialize(={}) super() @target = [:target] @association_name = [:association_name] end |
Instance Attribute Details
#association_name ⇒ Object (readonly)
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 (readonly)
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 |