Class: Trebuchet::Strategy::Multiple
- Defined in:
- lib/trebuchet/strategy/multiple.rb
Instance Attribute Summary collapse
-
#strategies ⇒ Object
readonly
Returns the value of attribute strategies.
Attributes inherited from Base
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #export ⇒ Object
-
#feature=(f) ⇒ Object
override setter so that @feature gets set on @strategies as well.
-
#initialize(args) ⇒ Multiple
constructor
A new instance of Multiple.
- #launch_at?(user, request = nil) ⇒ Boolean
- #needs_user? ⇒ Boolean
Methods inherited from Base
#feature_id, #inspect, #name, strategy_name
Constructor Details
Instance Attribute Details
#strategies ⇒ Object (readonly)
Returns the value of attribute strategies.
3 4 5 |
# File 'lib/trebuchet/strategy/multiple.rb', line 3 def strategies @strategies end |
Instance Method Details
#as_json(options = {}) ⇒ Object
23 24 25 |
# File 'lib/trebuchet/strategy/multiple.rb', line 23 def as_json( = {}) @strategies end |
#export ⇒ Object
33 34 35 |
# File 'lib/trebuchet/strategy/multiple.rb', line 33 def export super :strategies => strategies.map(&:export) end |
#feature=(f) ⇒ Object
override setter so that @feature gets set on @strategies as well
13 14 15 16 |
# File 'lib/trebuchet/strategy/multiple.rb', line 13 def feature=(f) @feature = f @strategies.each {|s| s.feature = f} end |
#launch_at?(user, request = nil) ⇒ Boolean
18 19 20 21 |
# File 'lib/trebuchet/strategy/multiple.rb', line 18 def launch_at?(user, request = nil) !!(strategies.select{|s| !user.nil? || !s.needs_user?}.find { |s| s.launch_at?(user, request) }) # !!(strategies.find { |s| s.launch_at?(user, request) }) end |
#needs_user? ⇒ Boolean
27 28 29 30 31 |
# File 'lib/trebuchet/strategy/multiple.rb', line 27 def needs_user? false # assume some of the strategies may not need user # could change this so it calls only the strategies that don't need a user when none is present # strategies.any? { |s| s.needs_user? } end |