Module: RestMyCase::Validator::ClassMethods

Included in:
RestMyCase::Validator
Defined in:
lib/rest_my_case/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clear_errorsObject (readonly)

Returns the value of attribute clear_errors.



9
10
11
# File 'lib/rest_my_case/validator.rb', line 9

def clear_errors
  @clear_errors
end

#validatorsObject



28
29
30
# File 'lib/rest_my_case/validator.rb', line 28

def validators
  @validators ||= Hash.new { |hash, key| hash[key] = [] }
end

Instance Method Details

#clear_errors!Object



24
25
26
# File 'lib/rest_my_case/validator.rb', line 24

def clear_errors!
  @clear_errors = true
end

#target(target_name) ⇒ Object



20
21
22
# File 'lib/rest_my_case/validator.rb', line 20

def target(target_name)
  @target_name = target_name
end

#target_nameObject



16
17
18
# File 'lib/rest_my_case/validator.rb', line 16

def target_name
  @target_name || Helpers.super_method(self, :target_name)
end

#trial_courtObject



11
12
13
14
# File 'lib/rest_my_case/validator.rb', line 11

def trial_court
  @trial_court ||= Trial::Court.new \
    Judge::Base, DefenseAttorney::Base, RestMyCase::Validator
end

#validate(*args, &block) ⇒ Object



32
33
34
# File 'lib/rest_my_case/validator.rb', line 32

def validate(*args, &block)
  validators[nil] << AccusationAttorneys::Custom.new(args, &block)
end

#validates_with(*args, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/rest_my_case/validator.rb', line 36

def validates_with(*args, &block)
  options = Helpers.extract_options!(args)

  options[:class] = self

  args.each do |klass|
    store_validators_by_attribute klass.new(options, &block)
  end
end