Class: Micro::Case
- Inherits:
-
Object
show all
- Includes:
- Attributes::Features::ActiveModelValidations
- Defined in:
- lib/micro/case.rb,
lib/micro/case/flow.rb,
lib/micro/case/safe.rb,
lib/micro/case/error.rb,
lib/micro/case/result.rb,
lib/micro/case/strict.rb,
lib/micro/case/version.rb,
lib/micro/case/safe/flow.rb,
lib/micro/case/flow/reducer.rb,
lib/micro/case/with_validation.rb
Defined Under Namespace
Modules: Error, Flow
Classes: Result, Safe, Strict
Constant Summary
collapse
- VERSION =
'2.1.0'.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(input) ⇒ Case
Returns a new instance of Case.
71
72
73
74
|
# File 'lib/micro/case.rb', line 71
def initialize(input)
@__input = input
self.attributes = input
end
|
Class Method Details
.&(use_case) ⇒ Object
31
32
33
|
# File 'lib/micro/case.rb', line 31
def self.&(use_case)
Safe::Flow([self, use_case])
end
|
.>>(use_case) ⇒ Object
27
28
29
|
# File 'lib/micro/case.rb', line 27
def self.>>(use_case)
Flow([self, use_case])
end
|
.__get_flow__ ⇒ Object
45
46
47
|
# File 'lib/micro/case.rb', line 45
def self.__get_flow__
@__flow
end
|
.__new__(result, arg) ⇒ Object
39
40
41
42
43
|
# File 'lib/micro/case.rb', line 39
def self.__new__(result, arg)
instance = new(arg)
instance.__set_result__(result)
instance
end
|
.auto_validation_disabled? ⇒ Boolean
9
10
11
|
# File 'lib/micro/case/with_validation.rb', line 9
def self.auto_validation_disabled?
@disable_auto_validation
end
|
.call(options = {}) ⇒ Object
35
36
37
|
# File 'lib/micro/case.rb', line 35
def self.call(options = {})
new(options).call
end
|
.call! ⇒ Object
61
62
63
64
65
66
67
68
69
|
# File 'lib/micro/case.rb', line 61
def self.call!
return const_get(:Flow_Step) if const_defined?(:Flow_Step)
const_set(:Flow_Step, Class.new(self) do
private def __call
__call_use_case
end
end)
end
|
.disable_auto_validation ⇒ Object
13
14
15
|
# File 'lib/micro/case/with_validation.rb', line 13
def self.disable_auto_validation
@disable_auto_validation = true
end
|
.flow(*args) ⇒ Object
57
58
59
|
# File 'lib/micro/case.rb', line 57
def self.flow(*args)
@__flow ||= __set_flow__(Flow::Reducer, args)
end
|
.Flow(args) ⇒ Object
23
24
25
|
# File 'lib/micro/case.rb', line 23
def self.Flow(args)
Flow::Reducer.build(Array(args))
end
|
.to_proc ⇒ Object
19
20
21
|
# File 'lib/micro/case.rb', line 19
def self.to_proc
Proc.new { |arg| call(arg) }
end
|
.use_cases ⇒ Object
50
|
# File 'lib/micro/case.rb', line 50
def self.use_cases; __get_flow__.use_cases; end
|
Instance Method Details
#__set_result__(result) ⇒ Object
#call ⇒ Object
80
81
82
|
# File 'lib/micro/case.rb', line 80
def call
__call
end
|
#call! ⇒ Object
76
77
78
|
# File 'lib/micro/case.rb', line 76
def call!
raise NotImplementedError
end
|