Class: Ucasy::Base
Direct Known Subclasses
Flow
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Callable
#call
Constructor Details
#initialize(context = {}) ⇒ Base
Returns a new instance of Base.
24
25
26
|
# File 'lib/ucasy/base.rb', line 24
def initialize(context = {})
@context = Context.build(context)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, &block) ⇒ Object
71
72
73
|
# File 'lib/ucasy/base.rb', line 71
def method_missing(method_name, *, &block)
context.public_send(method_name)
end
|
Class Attribute Details
.validator_attribute_keys ⇒ Object
Returns the value of attribute validator_attribute_keys.
13
14
15
|
# File 'lib/ucasy/base.rb', line 13
def validator_attribute_keys
@validator_attribute_keys
end
|
.validator_class ⇒ Object
Returns the value of attribute validator_class.
13
14
15
|
# File 'lib/ucasy/base.rb', line 13
def validator_class
@validator_class
end
|
Class Method Details
._required_attributes ⇒ Object
19
20
21
|
# File 'lib/ucasy/base.rb', line 19
def _required_attributes
@required_attributes || []
end
|
.call(context = {}) ⇒ Object
4
5
6
|
# File 'lib/ucasy/base.rb', line 4
def call(context = {})
new(context).perform
end
|
.required_attributes(*attributes) ⇒ Object
15
16
17
|
# File 'lib/ucasy/base.rb', line 15
def required_attributes(*attributes)
@required_attributes = attributes
end
|
.validate(validator_class, *validator_attribute_keys) ⇒ Object
8
9
10
11
|
# File 'lib/ucasy/base.rb', line 8
def validate(validator_class, *validator_attribute_keys)
@validator_class = validator_class
@validator_attribute_keys = validator_attribute_keys
end
|
Instance Method Details
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/ucasy/base.rb', line 28
def perform
return if failure?
validate!
validate_required_attributes!
try(:before) if success?
call if success?
try(:after) if success?
self
rescue Failure
self
end
|