Class: Validation::Generator
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.
Constructor Details
#initialize(receiver, &block) ⇒ Generator
Initializes a new generator.
80 81 82 83 |
# File 'lib/assistance/validation.rb', line 80 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.
86 87 88 |
# File 'lib/assistance/validation.rb', line 86 def method_missing(m, *args, &block) @receiver.send(:"validates_#{m}", *args, &block) end |