Module: UseCases::ModuleOptins::Validated::ClassMethods
- Defined in:
- lib/use_cases/module_optins/validated.rb
Instance Method Summary collapse
- #_contract_class ⇒ Object
- #_contract_class_defined? ⇒ Boolean
- #_contract_class_name ⇒ Object
- #_define_contract_class ⇒ Object
- #_define_validation_step ⇒ Object
- #_setup_validation ⇒ Object
- #_validation_step_defined? ⇒ Boolean
Instance Method Details
#_contract_class ⇒ Object
100 101 102 |
# File 'lib/use_cases/module_optins/validated.rb', line 100 def _contract_class self::Contract end |
#_contract_class_defined? ⇒ Boolean
112 113 114 |
# File 'lib/use_cases/module_optins/validated.rb', line 112 def _contract_class_defined? Object.const_defined? _contract_class_name end |
#_contract_class_name ⇒ Object
108 109 110 |
# File 'lib/use_cases/module_optins/validated.rb', line 108 def _contract_class_name "#{name}::Contract" end |
#_define_contract_class ⇒ Object
104 105 106 |
# File 'lib/use_cases/module_optins/validated.rb', line 104 def _define_contract_class const_set(:Contract, Class.new(Dry::Validation::Contract)) end |
#_define_validation_step ⇒ Object
96 97 98 |
# File 'lib/use_cases/module_optins/validated.rb', line 96 def _define_validation_step step :validate end |
#_setup_validation ⇒ Object
91 92 93 94 |
# File 'lib/use_cases/module_optins/validated.rb', line 91 def _setup_validation _define_contract_class unless _contract_class_defined? _define_validation_step unless _validation_step_defined? end |
#_validation_step_defined? ⇒ Boolean
116 117 118 |
# File 'lib/use_cases/module_optins/validated.rb', line 116 def _validation_step_defined? __steps__.map(&:name).include?(:validate) end |