Class: RuleBox::Strategy
- Inherits:
-
Object
- Object
- RuleBox::Strategy
- Includes:
- MethodHelper
- Defined in:
- lib/rule_box/strategy.rb
Class Attribute Summary collapse
-
.description ⇒ Object
readonly
Returns the value of attribute description.
Instance Attribute Summary collapse
-
#facade ⇒ Object
readonly
Returns the value of attribute facade.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(facade = nil) ⇒ Strategy
constructor
A new instance of Strategy.
- #instance_values ⇒ Object
- #perform ⇒ Object
Methods included from MethodHelper
Constructor Details
#initialize(facade = nil) ⇒ Strategy
Returns a new instance of Strategy.
12 13 14 |
# File 'lib/rule_box/strategy.rb', line 12 def initialize(facade = nil) @facade = facade end |
Class Attribute Details
.description ⇒ Object (readonly)
Returns the value of attribute description.
32 33 34 |
# File 'lib/rule_box/strategy.rb', line 32 def description @description end |
Instance Attribute Details
#facade ⇒ Object (readonly)
Returns the value of attribute facade.
6 7 8 |
# File 'lib/rule_box/strategy.rb', line 6 def facade @facade end |
Class Method Details
.desc(description) ⇒ Object
34 35 36 |
# File 'lib/rule_box/strategy.rb', line 34 def desc(description) @description = description end |
.perform(&block) ⇒ Object
38 39 40 41 42 |
# File 'lib/rule_box/strategy.rb', line 38 def perform(&block) define_method :perform do |result = nil| instance_exec(result, &block) end end |
Instance Method Details
#instance_values ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rule_box/strategy.rb', line 20 def instance_values hash = { strategy_name: self.class.name } instance_variables.each do |name| next if name == :@facade hash[name[1..]] = instance_variable_get(name) end hash end |
#perform ⇒ Object
16 17 18 |
# File 'lib/rule_box/strategy.rb', line 16 def perform raise 'Must implement this method' end |