Class: DelegateValidation::Validator
- Inherits:
-
Object
- Object
- DelegateValidation::Validator
- Includes:
- Validateable
- Defined in:
- app/models/delegate_validation.rb
Overview
rubocop:enable Metrics/MethodLength
Direct Known Subclasses
AlwaysValidValidator, PacBioSamplePrepRequest::RequestOptionsValidator, PacBioSequencingRequest::RequestOptionsValidator, RequestType::Validation::RequestTypeValidator, SequencingRequest::RequestOptionsValidator
Defined Under Namespace
Classes: DelegateError
Class Method Summary collapse
-
.delegate_attribute(*args) ⇒ Object
rubocop:todo Metrics/MethodLength.
- .name ⇒ Object
Instance Method Summary collapse
-
#initialize(target) ⇒ Validator
constructor
A new instance of Validator.
Methods included from Validateable
append_features, #method_missing, #validate!
Constructor Details
#initialize(target) ⇒ Validator
Returns a new instance of Validator.
46 47 48 |
# File 'app/models/delegate_validation.rb', line 46 def initialize(target) @target = target end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Validateable
Class Method Details
.delegate_attribute(*args) ⇒ Object
rubocop:todo Metrics/MethodLength
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/models/delegate_validation.rb', line 50 def self.delegate_attribute(*args) # rubocop:todo Metrics/MethodLength = args. type_cast = ".#{[:type_cast]}" if .key?(:type_cast) && [:type_cast].present? default = " || #{[:default].inspect}" if .key?(:default) args.each do |attribute| line = __LINE__ + 1 class_eval( " def #{attribute}_before_type_cast #{[:to]}.#{attribute} #{default} end def #{attribute} #{attribute}_before_type_cast#{type_cast} end def #{attribute}_needs_checking? #{attribute}_before_type_cast.present? or include_unset_values? end ", __FILE__, line ) end end |
.name ⇒ Object
42 43 44 |
# File 'app/models/delegate_validation.rb', line 42 def self.name 'Nothing' end |