Class: SampleModels::Model::Validation
- Inherits:
-
Object
- Object
- SampleModels::Model::Validation
- Defined in:
- lib/sample_models/model.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, config = {}) ⇒ Validation
constructor
A new instance of Validation.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(type, config = {}) ⇒ Validation
Returns a new instance of Validation.
96 97 98 |
# File 'lib/sample_models/model.rb', line 96 def initialize(type, config = {}) @type, @config = type, config end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sample_models/model.rb', line 100 def method_missing(meth, *args, &block) type_predicates = %w( email_format? inclusion? length? presence? uniqueness? ) if type_predicates.include?(meth.to_s) @type == "validates_#{meth.to_s.chop}_of".to_sym else super end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
94 95 96 |
# File 'lib/sample_models/model.rb', line 94 def config @config end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
94 95 96 |
# File 'lib/sample_models/model.rb', line 94 def type @type end |