Class: Bali::MapRulesDsl

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMapRulesDsl

Returns a new instance of MapRulesDsl.



85
86
87
# File 'lib/bali.rb', line 85

def initialize
  @@lock = Mutex.new
end

Instance Attribute Details

#current_rule_classObject

Returns the value of attribute current_rule_class.



83
84
85
# File 'lib/bali.rb', line 83

def current_rule_class
  @current_rule_class
end

Instance Method Details

#rules_for(target_class, target_alias_hash = {}, &block) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/bali.rb', line 89

def rules_for(target_class, target_alias_hash = {}, &block)
  @@lock.synchronize do
    self.current_rule_class = Bali::RuleClass.new(target_class)
    self.current_rule_class.alias_name = target_alias_hash[:as] || target_alias_hash["as"]

    Bali::MapRulesRulesForDsl.new(self).instance_eval(&block)

    # done processing the block, now add the rule class
    Bali.add_rule_class(self.current_rule_class)
  end
end