Module: UseCases::ModuleOptins::Validated::ClassMethods

Defined in:
lib/use_cases/module_optins/validated.rb

Instance Method Summary collapse

Instance Method Details

#_contract_classObject



100
101
102
# File 'lib/use_cases/module_optins/validated.rb', line 100

def _contract_class
  self::Contract
end

#_contract_class_defined?Boolean

Returns:

  • (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_nameObject



108
109
110
# File 'lib/use_cases/module_optins/validated.rb', line 108

def _contract_class_name
  "#{name}::Contract"
end

#_define_contract_classObject



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_stepObject



96
97
98
# File 'lib/use_cases/module_optins/validated.rb', line 96

def _define_validation_step
  step :validate
end

#_setup_validationObject



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

Returns:

  • (Boolean)


116
117
118
# File 'lib/use_cases/module_optins/validated.rb', line 116

def _validation_step_defined?
  __steps__.map(&:name).include?(:validate)
end