Class: Bali::RuleClass
- Inherits:
-
Object
- Object
- Bali::RuleClass
- Defined in:
- lib/bali/rule_class.rb
Overview
the parent of all Bali::RuleGroup.
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
Returns the value of attribute alias_name.
-
#rule_groups ⇒ Object
Returns the value of attribute rule_groups.
-
#target_class ⇒ Object
readonly
Returns the value of attribute target_class.
Instance Method Summary collapse
- #add_rule_group(rule_group) ⇒ Object
-
#initialize(target_class) ⇒ RuleClass
constructor
A new instance of RuleClass.
- #rules_for(subtarget) ⇒ Object
Constructor Details
#initialize(target_class) ⇒ RuleClass
8 9 10 11 12 13 14 15 16 |
# File 'lib/bali/rule_class.rb', line 8 def initialize(target_class) if target_class.is_a?(Class) @target_class = target_class else raise Bali::DslError, "Target class must be a Class" end self.rule_groups = {} end |
Instance Attribute Details
#alias_name ⇒ Object
Returns the value of attribute alias_name.
4 5 6 |
# File 'lib/bali/rule_class.rb', line 4 def alias_name @alias_name end |
#rule_groups ⇒ Object
Returns the value of attribute rule_groups.
6 7 8 |
# File 'lib/bali/rule_class.rb', line 6 def rule_groups @rule_groups end |
#target_class ⇒ Object (readonly)
Returns the value of attribute target_class.
3 4 5 |
# File 'lib/bali/rule_class.rb', line 3 def target_class @target_class end |
Instance Method Details
#add_rule_group(rule_group) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/bali/rule_class.rb', line 18 def add_rule_group(rule_group) if rule_group.is_a?(Bali::RuleGroup) target_user = rule_group.subtarget self.rule_groups[Bali::RuleGroup.canon_name(target_user)] = rule_group else raise Bali::DslError, "Rule group must be an instance of Bali::RuleGroup" end end |
#rules_for(subtarget) ⇒ Object
27 28 29 30 |
# File 'lib/bali/rule_class.rb', line 27 def rules_for(subtarget) subtarget = Bali::RuleGroup.canon_name(subtarget) self.rule_groups[subtarget] end |