Module: Metaractor
- Defined in:
- lib/metaractor/parameters.rb,
lib/metaractor.rb,
lib/metaractor/spec.rb,
lib/metaractor/errors.rb,
lib/metaractor/version.rb,
lib/metaractor/namespace.rb,
lib/metaractor/organizer.rb,
lib/metaractor/handle_errors.rb,
lib/metaractor/chain_failures.rb,
lib/metaractor/context_errors.rb,
lib/metaractor/failure_output.rb,
lib/metaractor/context_methods.rb,
lib/metaractor/run_with_context.rb
Overview
Special thanks to the ‘hashie` and `active_attr` gems for code and inspiration.
Defined Under Namespace
Modules: ChainFailures, ContextErrors, ContextMethods, FailureOutput, HandleErrors, Namespace, Organizer, Parameters, RunWithContext, Spec
Classes: Error, Errors, InvalidError
Constant Summary
collapse
- VERSION =
"3.3.5"
Class Method Summary
collapse
Class Method Details
.clear_types! ⇒ Object
88
89
90
|
# File 'lib/metaractor.rb', line 88
def self.clear_types!
@types = {}
end
|
30
31
32
|
# File 'lib/metaractor.rb', line 30
def self.configure
yield self
end
|
68
69
70
|
# File 'lib/metaractor.rb', line 68
def self.default_hash_formatter
->(hash) { hash.inspect }
end
|
.default_modules ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/metaractor.rb', line 42
def self.default_modules
[
{module: Metaractor::HandleErrors, method: :include},
{module: Metaractor::Parameters, method: :include},
{module: Metaractor::RunWithContext, method: :include},
{module: Metaractor::ChainFailures, method: :include},
{module: Metaractor::Namespace, method: :include}
]
end
|
60
61
62
63
64
65
66
|
# File 'lib/metaractor.rb', line 60
def self.format_hash(hash)
if @hash_formatter.nil?
@hash_formatter = default_hash_formatter
end
@hash_formatter.call(hash)
end
|
72
73
74
|
# File 'lib/metaractor.rb', line 72
def self.hash_formatter
@hash_formatter
end
|
76
77
78
|
# File 'lib/metaractor.rb', line 76
def self.hash_formatter=(callable)
@hash_formatter = callable
end
|
.include_module(mod) ⇒ Object
52
53
54
|
# File 'lib/metaractor.rb', line 52
def self.include_module(mod)
modules << {module: mod, method: :include}
end
|
.included(base) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/metaractor.rb', line 16
def self.included(base)
base.class_eval do
include Interactor
Metaractor.modules.each do |hsh|
case hsh[:method]
when :include
include hsh[:module]
when :prepend
prepend hsh[:module]
end
end
end
end
|
.modules ⇒ Object
34
35
36
|
# File 'lib/metaractor.rb', line 34
def self.modules
@modules ||= default_modules
end
|
.modules=(mods) ⇒ Object
38
39
40
|
# File 'lib/metaractor.rb', line 38
def self.modules=(mods)
@modules = mods
end
|
.prepend_module(mod) ⇒ Object
56
57
58
|
# File 'lib/metaractor.rb', line 56
def self.prepend_module(mod)
modules << {module: mod, method: :prepend}
end
|
.register_type(type, callable) ⇒ Object
84
85
86
|
# File 'lib/metaractor.rb', line 84
def self.register_type(type, callable)
types[type] = callable
end
|
.types ⇒ Object
80
81
82
|
# File 'lib/metaractor.rb', line 80
def self.types
@types ||= {}
end
|