Sha256: 59200fca96abe8ca183bdec4572abcb9834c0fa29ca7883803f44cb1a95e83e6

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

module Rasti
  class App
    class Interaction

      def self.build_form(params)
        constants.include?(:Form) ? const_get(:Form).new(params) : Form.new
      end

      def initialize(container, context)
        @container = container
        @context = context
      end

      def call(params)
        Thread.current[thread_form_key] = self.class.build_form(params)
        execute
      ensure
        Thread.current[thread_form_key] = nil
      end

      private

      attr_reader :container, :context

      def form
        Thread.current[thread_form_key]
      end

      def thread_form_key
        "#{self.class.name}::Form[#{self.object_id}]"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rasti-app-0.0.2 lib/rasti/app/interaction.rb
rasti-app-0.0.1 lib/rasti/app/interaction.rb