Sha256: 0f9fa372fc5286f11259135545c7f22b8b127f5e952903acbe448358aa2f6dcb

Contents?: true

Size: 857 Bytes

Versions: 21

Compression:

Stored size: 857 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
        @uuid = SecureRandom.uuid
      end

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

      private

      attr_reader :environment, :session, :uuid

      def form
        thread_cache[:form]
      end

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

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

    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rasti-app-11.0.0 lib/rasti/app/interaction.rb
rasti-app-10.0.1 lib/rasti/app/interaction.rb
rasti-app-10.0.0 lib/rasti/app/interaction.rb
rasti-app-9.0.0 lib/rasti/app/interaction.rb
rasti-app-8.0.1 lib/rasti/app/interaction.rb
rasti-app-8.0.0 lib/rasti/app/interaction.rb
rasti-app-7.1.1 lib/rasti/app/interaction.rb
rasti-app-7.1.0 lib/rasti/app/interaction.rb
rasti-app-7.0.2 lib/rasti/app/interaction.rb
rasti-app-7.0.1 lib/rasti/app/interaction.rb
rasti-app-7.0.0 lib/rasti/app/interaction.rb
rasti-app-6.0.1 lib/rasti/app/interaction.rb
rasti-app-6.0.0 lib/rasti/app/interaction.rb
rasti-app-5.0.0 lib/rasti/app/interaction.rb
rasti-app-4.0.2 lib/rasti/app/interaction.rb
rasti-app-4.0.1 lib/rasti/app/interaction.rb
rasti-app-4.0.0 lib/rasti/app/interaction.rb
rasti-app-3.0.0 lib/rasti/app/interaction.rb
rasti-app-2.2.4 lib/rasti/app/interaction.rb
rasti-app-2.2.3 lib/rasti/app/interaction.rb