Sha256: 7f2223e8d9d84d1babf9306cd18628cc764d9db5313563586aa165543164021d

Contents?: true

Size: 826 Bytes

Versions: 7

Compression:

Stored size: 826 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(environment, session)
        @environment = environment
        @session = session
      end

      def call(form)
        thread_cache[:form] = form
        validate!
        execute
      ensure
        thread_cache[:form] = nil
      end

      private

      attr_reader :environment, :session

      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

7 entries across 7 versions & 1 rubygems

Version Path
rasti-app-2.2.1 lib/rasti/app/interaction.rb
rasti-app-2.2.0 lib/rasti/app/interaction.rb
rasti-app-2.1.1 lib/rasti/app/interaction.rb
rasti-app-2.1.0 lib/rasti/app/interaction.rb
rasti-app-2.0.0 lib/rasti/app/interaction.rb
rasti-app-1.1.0 lib/rasti/app/interaction.rb
rasti-app-1.0.0 lib/rasti/app/interaction.rb