Sha256: 625882272f111324a65e742b6a8f0201f0096b667fc3c8cc4e774894dfc154af

Contents?: true

Size: 745 Bytes

Versions: 1

Compression:

Stored size: 745 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.current[thread_form_key] = self.class.build_form(params)
        validate!
        execute
      ensure
        Thread.current[thread_form_key] = nil
      end

      private

      attr_reader :container, :context

      def form
        Thread.current[thread_form_key]
      end

      def thread_form_key
        "#{self.class.name}::Form[#{self.object_id}]"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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