Class: Sequel::Plugins::ValidationClassMethods::ClassMethods::Generator
- Defined in:
- lib/sequel/plugins/validation_class_methods.rb
Overview
The Generator class is used to generate validation definitions using the validates {} idiom.
Instance Method Summary collapse
-
#initialize(receiver, &block) ⇒ Generator
constructor
Initializes a new generator.
-
#method_missing(m, *args, &block) ⇒ Object
Delegates method calls to the receiver by calling receiver.validates_xxx.
-
#respond_to_missing?(meth, include_private) ⇒ Boolean
This object responds to all validates_* methods the model responds to.
Constructor Details
#initialize(receiver, &block) ⇒ Generator
Initializes a new generator.
44 45 46 47 |
# File 'lib/sequel/plugins/validation_class_methods.rb', line 44 def initialize(receiver ,&block) @receiver = receiver instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
Delegates method calls to the receiver by calling receiver.validates_xxx.
50 51 52 |
# File 'lib/sequel/plugins/validation_class_methods.rb', line 50 def method_missing(m, *args, &block) @receiver.send(:"validates_#{m}", *args, &block) end |
Instance Method Details
#respond_to_missing?(meth, include_private) ⇒ Boolean
This object responds to all validates_* methods the model responds to.
55 56 57 |
# File 'lib/sequel/plugins/validation_class_methods.rb', line 55 def respond_to_missing?(meth, include_private) @receiver.respond_to?(:"validates_#{meth}", include_private) end |