Class: Solid::Process
- Inherits:
-
Object
show all
- Extended by:
- ClassMethods
- Includes:
- ActiveSupport::Rescuable, Callbacks
- Defined in:
- lib/solid/process/caller.rb,
lib/solid/process.rb,
lib/solid/process/error.rb,
lib/solid/process/config.rb,
lib/solid/process/version.rb,
lib/solid/process/callbacks.rb,
lib/solid/process/event_logs.rb,
lib/solid/process/active_record.rb,
lib/solid/process/class_methods.rb
Overview
rubocop:disable Lint/RescueException
Defined Under Namespace
Modules: Callbacks, Caller, ClassMethods, EventLogs
Classes: BacktraceCleaner, Config
Constant Summary
collapse
- Error =
::Class.new(::StandardError)
- VERSION =
"0.3.0"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Callbacks
included
Constructor Details
#initialize(arg = nil) ⇒ Process
Returns a new instance of Process.
49
50
51
|
# File 'lib/solid/process.rb', line 49
def initialize(arg = nil)
self.dependencies = arg
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
89
90
91
|
# File 'lib/solid/process.rb', line 89
def method_missing(name, *args, &block)
name.end_with?("?") ? output&.is?(name.to_s.chomp("?")) : super
end
|
Instance Attribute Details
#dependencies ⇒ Object
Also known as:
deps
Returns the value of attribute dependencies.
47
48
49
|
# File 'lib/solid/process.rb', line 47
def dependencies
@dependencies
end
|
Returns the value of attribute input.
47
48
49
|
# File 'lib/solid/process.rb', line 47
def input
@input
end
|
#output ⇒ Object
Also known as:
result
Returns the value of attribute output.
47
48
49
|
# File 'lib/solid/process.rb', line 47
def output
@output
end
|
Class Method Details
.call(arg = nil) ⇒ Object
33
34
35
|
# File 'lib/solid/process.rb', line 33
def self.call(arg = nil)
new.call(arg)
end
|
.config ⇒ Object
43
44
45
|
# File 'lib/solid/process.rb', line 43
def self.config
Config.instance
end
|
.configuration {|config| ... } ⇒ Object
37
38
39
40
41
|
# File 'lib/solid/process.rb', line 37
def self.configuration(&block)
yield config
config.freeze
end
|
.inherited(subclass) ⇒ Object
27
28
29
30
31
|
# File 'lib/solid/process.rb', line 27
def self.inherited(subclass)
super
subclass.prepend(Caller)
end
|
Instance Method Details
#call(_arg = nil) ⇒ Object
53
54
55
|
# File 'lib/solid/process.rb', line 53
def call(_arg = nil)
raise Error, "#{self.class}#call must be implemented."
end
|
#dependencies? ⇒ Boolean
Also known as:
deps?
73
74
75
|
# File 'lib/solid/process.rb', line 73
def dependencies?
!dependencies.nil?
end
|
#failure?(type = nil) ⇒ Boolean
81
82
83
|
# File 'lib/solid/process.rb', line 81
def failure?(type = nil)
!!output&.failure?(type)
end
|
65
66
67
|
# File 'lib/solid/process.rb', line 65
def input?
!input.nil?
end
|
#inspect ⇒ Object
85
86
87
|
# File 'lib/solid/process.rb', line 85
def inspect
"#<#{self.class.name} dependencies=#{dependencies.inspect} input=#{input.inspect} output=#{output.inspect}>"
end
|
#new(dependencies = {}) ⇒ Object
61
62
63
|
# File 'lib/solid/process.rb', line 61
def new(dependencies = {})
with(dependencies)
end
|
#output?(type = nil) ⇒ Boolean
Also known as:
result?
69
70
71
|
# File 'lib/solid/process.rb', line 69
def output?(type = nil)
type.nil? ? !output.nil? : !!output&.is?(type)
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
93
94
95
|
# File 'lib/solid/process.rb', line 93
def respond_to_missing?(name, include_private = false)
name.end_with?("?") || super
end
|
#success?(type = nil) ⇒ Boolean
77
78
79
|
# File 'lib/solid/process.rb', line 77
def success?(type = nil)
!!output&.success?(type)
end
|
#with(dependencies) ⇒ Object
57
58
59
|
# File 'lib/solid/process.rb', line 57
def with(dependencies)
self.class.new(dependencies.with_indifferent_access.with_defaults(deps&.attributes))
end
|