Sha256: 7ac76770bf995032f17da3613134320d48dc451322bd8f229ffce991997ed2b0

Contents?: true

Size: 818 Bytes

Versions: 6

Compression:

Stored size: 818 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(form)
        thread_cache[:form] = form
        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

6 entries across 6 versions & 1 rubygems

Version Path
rasti-app-0.1.2 lib/rasti/app/interaction.rb
rasti-app-0.1.1 lib/rasti/app/interaction.rb
rasti-app-0.1.0 lib/rasti/app/interaction.rb
rasti-app-0.0.10 lib/rasti/app/interaction.rb
rasti-app-0.0.9 lib/rasti/app/interaction.rb
rasti-app-0.0.8 lib/rasti/app/interaction.rb