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.0.0'.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
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
|
.__failure_type(arg, type) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'lib/micro/case.rb', line 45
def self.__failure_type(arg, type)
return type if type != :error
case arg
when Exception then :exception
when Symbol then arg
else type
end
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
|
.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
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
|
Instance Method Details
#__set_result__(result) ⇒ Object
#call ⇒ Object
59
60
61
|
# File 'lib/micro/case.rb', line 59
def call
__call
end
|
#call! ⇒ Object
55
56
57
|
# File 'lib/micro/case.rb', line 55
def call!
raise NotImplementedError
end
|