Class: Trebuchet::Strategy::LogicBase

Inherits:
Base
  • Object
show all
Defined in:
lib/trebuchet/strategy/logic_base.rb

Direct Known Subclasses

LogicAnd, LogicNot, LogicOr

Instance Attribute Summary collapse

Attributes inherited from Base

#feature

Instance Method Summary collapse

Methods inherited from Base

#as_json, #export, #feature_id, #inspect, #name, strategy_name

Constructor Details

#initialize(options = {}) ⇒ LogicBase

Returns a new instance of LogicBase.



6
7
8
9
10
11
12
# File 'lib/trebuchet/strategy/logic_base.rb', line 6

def initialize(options = {})
  @options = options
  @strategies = []
  options.each do |strategy_name, strategy_options|
    @strategies << Trebuchet::Strategy.find(strategy_name.to_sym, strategy_options)
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/trebuchet/strategy/logic_base.rb', line 4

def options
  @options
end

#strategiesObject (readonly)

Returns the value of attribute strategies.



3
4
5
# File 'lib/trebuchet/strategy/logic_base.rb', line 3

def strategies
  @strategies
end

Instance Method Details

#feature=(f) ⇒ Object

Override feature setter so that @feature gets set on @strategies as well



15
16
17
18
# File 'lib/trebuchet/strategy/logic_base.rb', line 15

def feature=(f)
  @feature = f
  @strategies.each { |s| s.feature = f }
end

#launch_at?(user, request = nil) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/trebuchet/strategy/logic_base.rb', line 20

def launch_at?(user, request = nil)
  false # To be overriden in implementation classes.
end

#needs_user?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/trebuchet/strategy/logic_base.rb', line 24

def needs_user?
  false
end