class Argo::ConstraintProcessor
Constants
- NON_CONSTRAINT_PROPERTIES
Public Class Methods
new(dereferencer)
click to toggle source
# File lib/argo/constraint_processor.rb, line 13 def initialize(dereferencer) @dereferencer = dereferencer end
Public Instance Methods
process(hash)
click to toggle source
# File lib/argo/constraint_processor.rb, line 17 def process(hash) process_hash( hash.reject { |k, _| NON_CONSTRAINT_PROPERTIES.include?(k) } ) end
Private Instance Methods
process_hash(hash)
click to toggle source
# File lib/argo/constraint_processor.rb, line 42 def process_hash(hash) if reference?(hash) dereference(hash) else hash. map { |k, v| [symbolize_key(k), process_object(v)] }. to_h. freeze end end
process_object(obj)
click to toggle source
# File lib/argo/constraint_processor.rb, line 31 def process_object(obj) case obj when Hash process_hash(obj) when Array obj.map { |v| process_object(v) }.freeze else obj.freeze end end
symbolize_key(k)
click to toggle source
# File lib/argo/constraint_processor.rb, line 27 def symbolize_key(k) k.gsub(/[A-Z]/) { |m| "_#{m.downcase}" }.to_sym end