Hash parameters do not work outside of Rails - Ruby active_interaction

When using vanilla Ruby, including hash parameters does not work because the with_indifferent_access method has not been patched onto hashes and is required by lib/active_interaction/filters/hash_filter.rb. This is solved by:

require "active_support/core_ext/hash/indifferent_access"

Simple example:

require "active_interaction"

module ActiveInteractionTest
  class Interaction < ActiveInteraction::Base
    hash :parameters

    def execute
      puts "All is fine"
    end
  end
end
ActiveInteractionTest::Interaction.run(parameters: {})
/Users/arice/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/active_interaction-4.0.3/lib/active_interaction/filters/hash_filter.rb:47:in `adjust_output': undefined method `with_indifferent_access' for {}:Hash (NoMethodError)
Asked Oct 10 '21 04:10
avatar HashNotAdam
HashNotAdam

1 Answer:

I actually happened across this the other day (https://github.com/AaronLasseigne/active_interaction/commit/2d8ee0a64f83bfb396f3f45673150a3c3a66cc9a). It'll be in the next release. Thanks for reporting it though!

1
Answered Jul 03 '21 at 19:30
avatar  of AaronLasseigne
AaronLasseigne