Sha256: a13d31f76513fa90ca547ae439abcf7ff66a6601a25454bbd4f8b3e79e089b9f

Contents?: true

Size: 845 Bytes

Versions: 3

Compression:

Stored size: 845 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 self.asynchronic?
        false
      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

3 entries across 3 versions & 1 rubygems

Version Path
rasti-app-0.0.7 lib/rasti/app/interaction.rb
rasti-app-0.0.6 lib/rasti/app/interaction.rb
rasti-app-0.0.5 lib/rasti/app/interaction.rb