Class: ParamsReady::Helpers::Conditional

Inherits:
Object
  • Object
show all
Defined in:
lib/params_ready/helpers/conditional_block.rb

Direct Known Subclasses

ConditionalBlock

Instance Method Summary collapse

Constructor Details

#initialize(rule: nil) ⇒ Conditional

Returns a new instance of Conditional.



7
8
9
10
# File 'lib/params_ready/helpers/conditional_block.rb', line 7

def initialize(rule: nil)
  @rule = Helpers::Rule(rule)
  freeze
end

Instance Method Details

#perform?(general_rule, name) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
# File 'lib/params_ready/helpers/conditional_block.rb', line 12

def perform?(general_rule, name)
  if @rule.nil?
    general_rule
  else
    @rule.include?(name)
  end
end