Class: TarvitHelpers::HashPresenter::WithRules::RulesHolder

Inherits:
Object
  • Object
show all
Defined in:
lib/tarvit-helpers/modules/hash_presenter/with_rules.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRulesHolder

Returns a new instance of RulesHolder.



41
42
43
# File 'lib/tarvit-helpers/modules/hash_presenter/with_rules.rb', line 41

def initialize
  @rules = []
end

Instance Attribute Details

#rulesObject (readonly)

Returns the value of attribute rules.



39
40
41
# File 'lib/tarvit-helpers/modules/hash_presenter/with_rules.rb', line 39

def rules
  @rules
end

Instance Method Details

#rule_for(path) ⇒ Object



49
50
51
# File 'lib/tarvit-helpers/modules/hash_presenter/with_rules.rb', line 49

def rule_for(path)
  rules.find{|r| r.path == path }
end

#when(path, &_transform_value) ⇒ Object



45
46
47
# File 'lib/tarvit-helpers/modules/hash_presenter/with_rules.rb', line 45

def when(path, &_transform_value)
  self.rules << Rule.new(path, _transform_value)
end