Module: Olyx::Guardrails::PolicyComponents::RuleNormalizer

Defined in:
lib/olyx/guardrails/policy/rule_normalizer.rb

Overview

Converts policy rule Hashes into immutable PolicyRule values.

Constant Summary collapse

ERROR =
'policy rules must be an Array of PolicyRule or Hash values'

Class Method Summary collapse

Class Method Details

.call(value) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
# File 'lib/olyx/guardrails/policy/rule_normalizer.rb', line 12

def call(value)
  return value if value.is_a?(PolicyRule)
  return PolicyRule.new(**ConfigurationHash.call(value)) if value.is_a?(Hash)

  raise ArgumentError, ERROR
end