Module: UseCase

Extended by:
UseCases::DSL, UseCases::ModuleOptins
Defined in:
lib/use_case.rb

Constant Summary

Constants included from UseCases::ModuleOptins

UseCases::ModuleOptins::OPTINS

Instance Attribute Summary collapse

Attributes included from UseCases::ModuleOptins

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UseCases::DSL

__steps__, register_adapter, remove_step

Methods included from UseCases::ModuleOptins

[], descendants

Instance Attribute Details

#stackObject (readonly)

Returns the value of attribute stack.



34
35
36
# File 'lib/use_case.rb', line 34

def stack
  @stack
end

Class Method Details

.included(base) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/use_case.rb', line 20

def self.included(base)
  super
  base.class_eval do
    include Dry::Monads[:result]
    include Dry::Monads::Do.for(:call)
    include Dry::Matcher.for(:call, with: Dry::Matcher::ResultMatcher)

    extend UseCases::DSL
    extend UseCases::ModuleOptins

    include UseCases::StepAdapters
  end
end

Instance Method Details

#call(params, current_user = nil) ⇒ Object



40
41
42
43
# File 'lib/use_case.rb', line 40

def call(params, current_user = nil)
  params = UseCases::Params.new(params)
  do_call(params, current_user)
end

#initializeObject



36
37
38
# File 'lib/use_case.rb', line 36

def initialize(*)
  @stack = UseCases::Stack.new(self.class.__steps__).bind(self)
end