Sha256: 3565268a5d8282895e423a4398238efddb3ad0501be25337cc2a9a0c192da551

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

module Rasti
  class App
    class Interaction

      include Rasti::Form::Validable

      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_cache[:form] = self.class.build_form(params)
        validate!
        execute
      ensure
        thread_cache[:form] = nil
      end

      private

      attr_reader :container, :context

      def form
        thread_cache[:form]
      end

      def thread_cache
        Thread.current[thread_cache_key] ||= {}
      end

      def thread_cache_key
        "#{self.class.name}[#{self.object_id}]"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rasti-app-0.0.4 lib/rasti/app/interaction.rb