Class: Strategize::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/strategize/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Create a new instance of [Configuration] class.



6
7
8
9
# File 'lib/strategize/configuration.rb', line 6

def initialize
  @rule_evaluator = Strategize::RuleEvaluator
  @policy_evaluator = Strategize::PolicyEvaluator
end

Instance Attribute Details

#policy_evaluatorObject

Returns the value of attribute policy_evaluator.



3
4
5
# File 'lib/strategize/configuration.rb', line 3

def policy_evaluator
  @policy_evaluator
end

#rule_evaluatorObject

Returns the value of attribute rule_evaluator.



3
4
5
# File 'lib/strategize/configuration.rb', line 3

def rule_evaluator
  @rule_evaluator
end

Instance Method Details

#add_policy_group(name) {|policy_group| ... } ⇒ Object

Add a policy group to the policy_groups hash

Parameters:

  • name (Symbol)

    a descriptive name for the [PolicyGroup]

  • the (Proc)

    block of code detailing which [Policy] to add

Yields:



48
49
50
51
52
# File 'lib/strategize/configuration.rb', line 48

def add_policy_group(name)
  policy_groups[name] = PolicyGroup.new unless policy_groups.key?(name)
  policy_group = policy_groups[name]
  yield(policy_group)
end

#policy_group(name) ⇒ PolicyGroup

Get a specific [PolicyGroup] that has been defined in [Configuration]

Parameters:

  • name (Symbol)

    the name of the policy-group that you want

Returns:



58
59
60
# File 'lib/strategize/configuration.rb', line 58

def policy_group(name)
  policy_groups[name]
end

#policy_groupsHash

Get a hash of all the policies groups that have been defined

Returns:

  • (Hash)


40
41
42
# File 'lib/strategize/configuration.rb', line 40

def policy_groups
  @policy_groups ||= {}
end