Module: Lasershark

Defined in:
lib/lasershark.rb,
lib/lasershark/version.rb,
lib/lasershark/common_context.rb,
lib/lasershark/context_methods.rb

Defined Under Namespace

Modules: CommonContext, ContextMethods

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lasershark.rb', line 7

def self.included(base)
  Interactor.class_eval do
    def initialize(context = {})
      @context = new_context(context)
    end

    def new_context(context)
      if context_class
        context_class.build(context)
      elsif context.class.respond_to?(:build)
        context.class.build(context)
      else
        Interactor::Context.build(context)
      end
    end

    def context_class
      self.class.context_class
    end
  end

  base.class_eval do
    include Interactor
    extend ContextMethods
  end
end