Module: Zen::Service::Plugins::Validation
- Extended by:
- Plugin
- Defined in:
- lib/zen/service/plugins/validation.rb
Defined Under Namespace
Classes: Errors
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Plugin
config, default_options, extended, register_as, service_extension
Class Method Details
.used(service_class) ⇒ Object
16
17
18
|
# File 'lib/zen/service/plugins/validation.rb', line 16
def self.used(service_class, *)
service_class.add_execution_prop(:errors)
end
|
Instance Method Details
#errors ⇒ Object
33
34
35
|
# File 'lib/zen/service/plugins/validation.rb', line 33
def errors
state.errors
end
|
#execute ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/zen/service/plugins/validation.rb', line 25
def execute(*)
return super if valid?
failure!(status: :invalid)
self
end
|
#valid? ⇒ Boolean
48
49
50
51
|
# File 'lib/zen/service/plugins/validation.rb', line 48
def valid?
validate!
errors.empty?
end
|
#validate ⇒ Object
46
|
# File 'lib/zen/service/plugins/validation.rb', line 46
def validate; end
|