Module: Floe::ValidationMixin
- Included in:
- Workflow::Catcher, Workflow::ChoiceRule, Workflow::Retrier, Workflow::State, WorkflowBase
- Defined in:
- lib/floe/validation_mixin.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #invalid_field_error!(field_name, field_value = nil, comment = nil) ⇒ Object
- #missing_field_error!(field_name) ⇒ Object
- #parser_error!(comment) ⇒ Object
- #runtime_field_error!(field_name, field_value, comment, floe_error: "States.Runtime") ⇒ Object
- #workflow_state?(field_value, workflow) ⇒ Boolean
- #wrap_parser_error(field_name, field_value) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/floe/validation_mixin.rb', line 5 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#invalid_field_error!(field_name, field_value = nil, comment = nil) ⇒ Object
17 18 19 |
# File 'lib/floe/validation_mixin.rb', line 17 def invalid_field_error!(field_name, field_value = nil, comment = nil) self.class.invalid_field_error!(name, field_name, field_value, comment) end |
#missing_field_error!(field_name) ⇒ Object
13 14 15 |
# File 'lib/floe/validation_mixin.rb', line 13 def missing_field_error!(field_name) self.class.missing_field_error!(name, field_name) end |
#parser_error!(comment) ⇒ Object
9 10 11 |
# File 'lib/floe/validation_mixin.rb', line 9 def parser_error!(comment) self.class.parser_error!(name, comment) end |
#runtime_field_error!(field_name, field_value, comment, floe_error: "States.Runtime") ⇒ Object
21 22 23 |
# File 'lib/floe/validation_mixin.rb', line 21 def runtime_field_error!(field_name, field_value, comment, floe_error: "States.Runtime") raise Floe::ExecutionError.new(self.class.field_error_text(name, field_name, field_value, comment), floe_error) end |
#workflow_state?(field_value, workflow) ⇒ Boolean
25 26 27 |
# File 'lib/floe/validation_mixin.rb', line 25 def workflow_state?(field_value, workflow) workflow.payload["States"] ? workflow.payload["States"].include?(field_value) : true end |
#wrap_parser_error(field_name, field_value) ⇒ Object
29 30 31 32 33 |
# File 'lib/floe/validation_mixin.rb', line 29 def wrap_parser_error(field_name, field_value) yield rescue ArgumentError, InvalidWorkflowError => error invalid_field_error!(field_name, field_value, error.) end |