Class: WorkflowTemplate::Definer::HasValidations::Validations::Unprepared
- Inherits:
-
Object
- Object
- WorkflowTemplate::Definer::HasValidations::Validations::Unprepared
- Defined in:
- lib/workflow_template/definer/has_validations/validations.rb
Instance Attribute Summary collapse
-
#declarations ⇒ Object
readonly
Returns the value of attribute declarations.
Class Method Summary collapse
Instance Method Summary collapse
- #add(declaration) ⇒ Object
- #freeze ⇒ Object
-
#initialize(declarations: {}, input_set: nil, output_set: nil) ⇒ Unprepared
constructor
A new instance of Unprepared.
- #prepared ⇒ Object
- #validate_input(entry) ⇒ Object
- #validate_output(entry) ⇒ Object
Constructor Details
#initialize(declarations: {}, input_set: nil, output_set: nil) ⇒ Unprepared
Returns a new instance of Unprepared.
43 44 45 46 47 |
# File 'lib/workflow_template/definer/has_validations/validations.rb', line 43 def initialize(declarations: {}, input_set: nil, output_set: nil) @declarations = declarations.freeze @input_set = Validations.normalize_entry(input_set) @output_set = Validations.normalize_entry(output_set) end |
Instance Attribute Details
#declarations ⇒ Object (readonly)
Returns the value of attribute declarations.
41 42 43 |
# File 'lib/workflow_template/definer/has_validations/validations.rb', line 41 def declarations @declarations end |
Class Method Details
.instance ⇒ Object
37 38 39 |
# File 'lib/workflow_template/definer/has_validations/validations.rb', line 37 def self.instance new end |
Instance Method Details
#add(declaration) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/workflow_template/definer/has_validations/validations.rb', line 51 def add(declaration) raise Error, "Declaration name taken: '#{declaration.name}'" if @declarations.key? declaration.name raise Error, "Validation '#{declaration.name}' not properly declared" unless valid_declaration?(declaration) @declarations = declarations.merge(declaration.name => declaration).freeze declaration end |
#freeze ⇒ Object
71 72 73 |
# File 'lib/workflow_template/definer/has_validations/validations.rb', line 71 def freeze raise Error, "Freeze is unimplemented for #{self.class.name}, call #prepared instead" end |
#prepared ⇒ Object
67 68 69 |
# File 'lib/workflow_template/definer/has_validations/validations.rb', line 67 def prepared Prepared.instance declarations: declarations, input: input_set, output: output_set end |
#validate_input(entry) ⇒ Object
59 60 61 |
# File 'lib/workflow_template/definer/has_validations/validations.rb', line 59 def validate_input(entry) @input_set = Validations.merge_entries(@input_set, entry) end |
#validate_output(entry) ⇒ Object
63 64 65 |
# File 'lib/workflow_template/definer/has_validations/validations.rb', line 63 def validate_output(entry) @output_set = Validations.merge_entries(@output_set, entry) end |