Module: RestMyCase::Validator::ClassMethods
- Included in:
- RestMyCase::Validator
- Defined in:
- lib/rest_my_case/validator.rb
Instance Attribute Summary collapse
-
#clear_errors ⇒ Object
readonly
Returns the value of attribute clear_errors.
- #validators ⇒ Object
Instance Method Summary collapse
- #clear_errors! ⇒ Object
- #target(target_name) ⇒ Object
- #target_name ⇒ Object
- #trial_court ⇒ Object
- #validate(*args, &block) ⇒ Object
- #validates_with(*args, &block) ⇒ Object
Instance Attribute Details
#clear_errors ⇒ Object (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 |
#validators ⇒ Object
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_name ⇒ Object
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_court ⇒ Object
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) = Helpers.(args) [:class] = self args.each do |klass| store_validators_by_attribute klass.new(, &block) end end |