Module | CustomValidations::SingletonValidateable
In: | lib/custom_validations.rb

### Methods

metaclass method_missing run_validations

### Public Instance methods

metaclass()

[Source]

        # File lib/custom_validations.rb, line 16
    16:     def metaclass
    17:       @metaclass ||= class << self; self; end
    18:     end

method_missing(sym, *args, &block)

[Source]

        # File lib/custom_validations.rb, line 46
    46:     def method_missing(sym, *args, &block)
    47:       if /\Avalidates_/ =~ sym.to_s
    48:         metaclass.__send__(sym, *args, &block)
    49:       else
    50:         super
    51:       end
    52:     end

run_validations(validation_method)

copy from activerecord-1.15.3/lib/active_record/validations.rb and add meta_validations

[Source]

        # File lib/custom_validations.rb, line 22
    22:     def run_validations(validation_method)
    23:       validations = self.class.read_inheritable_attribute(validation_method.to_sym)
    24:       meta_validations = metaclass.read_inheritable_attribute(validation_method.to_sym)
    25:       if validations.nil? && meta_validations.nil? then return end
    26:       validations = [validations, meta_validations].flatten.compact
    27:       validations.each do |validation|
    28:         if validation.is_a?(Symbol)
    29:           self.send(validation)
    30:         elsif validation.is_a?(String)
    31:           eval(validation, binding)
    32:         elsif validation_block?(validation)
    33:           validation.call(self)
    34:         elsif validation_class?(validation, validation_method)
    35:           validation.send(validation_method, self)
    36:         else
    37:           raise(
    38:             ActiveRecordError,
    39:             "Validations need to be either a symbol, string (to be eval'ed), proc/method, or " +
    40:             "class implementing a static validation method"
    41:             )
    42:         end
    43:       end
    44:     end

[Validate]