Module: ActiveInteraction::InputProcessor

Defined in:
lib/active_interaction/modules/input_processor.rb

Overview

Groups inputs ending in “(*N*i)” into GroupedInput.

Since:

  • 1.2.0

Class Method Summary collapse

Class Method Details

.process(inputs) ⇒ Object

Since:

  • 1.2.0



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_interaction/modules/input_processor.rb', line 30

def process(inputs)
  inputs.stringify_keys.sort.each_with_object({}) do |(k, v), h|
    next if reserved?(k)

    if (match = GROUPED_INPUT_PATTERN.match(k))
      assign_to_group!(h, *match.captures, v)
    else
      h[k.to_sym] = v
    end
  end
end

.reserved?(name) ⇒ Boolean

Checking ‘syscall` is the result of what appears to be a bug in Ruby. bugs.ruby-lang.org/issues/15597

Returns:

  • (Boolean)

Since:

  • 1.2.0



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_interaction/modules/input_processor.rb', line 17

def reserved?(name)
  name.to_s.start_with?('_interaction_') ||
    name == :syscall ||
    (
      Base.method_defined?(name) &&
      !Object.method_defined?(name)
    ) ||
    (
      Base.private_method_defined?(name) &&
      !Object.private_method_defined?(name)
    )
end