Module: ValidationGroup::ActiveRecord::Errors

Defined in:
lib/validation_group.rb

Overview

included in ActiveRecord::Errors

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



95
96
97
98
99
# File 'lib/validation_group.rb', line 95

def self.included(base) #:nodoc:
  base.class_eval do
    alias_method_chain :add, :validation_group
  end
end

Instance Method Details

#add_with_validation_group(attribute, msg = nil, *args, &block) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/validation_group.rb', line 87

def add_with_validation_group(attribute,
    msg = nil, *args,
    &block)
  # jeffp: setting @current_validation_fields and use of should_validate? optimizes code
  add_error = @base.respond_to?(:should_validate?) ? @base.should_validate?(attribute.to_sym) : true
  add_without_validation_group(attribute, msg, *args, &block) if add_error
end