Class: NotNaughty::Builder::ValidationDelegator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- NotNaughty::Builder::ValidationDelegator
- Defined in:
- lib/not_naughty/builder.rb
Overview
:nodoc:all
Instance Method Summary collapse
-
#initialize(receiver, *params) ⇒ ValidationDelegator
constructor
A new instance of ValidationDelegator.
-
#method_missing(method_sym, *params) ⇒ Object
:nodoc:.
Constructor Details
#initialize(receiver, *params) ⇒ ValidationDelegator
Returns a new instance of ValidationDelegator.
42 43 44 45 46 47 |
# File 'lib/not_naughty/builder.rb', line 42 def initialize(receiver, *params) @_sd_obj_opts = params. @_sd_obj_params = params super receiver end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *params) ⇒ Object
:nodoc:
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/not_naughty/builder.rb', line 48 def method_missing(method_sym, *params) #:nodoc: method_sym, params = unless @_sd_obj_params.empty? opts = @_sd_obj_opts.update params. [:"validates_#{method_sym}_of", @_sd_obj_params + [opts]] else opts = @_sd_obj_opts.update params. [:"validates_#{method_sym}", params + [opts]] end if @_sd_obj.respond_to? method_sym @_sd_obj.send!(method_sym, *params) return true else raise NoMethodError, "unable to evaluate ยด#{method_sym}(*#{params.inspect})'" end end |