Module: RestMyCase::Validator::ClassMethods
- Included in:
- RestMyCase::Validator
- Defined in:
- lib/rest_my_case/validator.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #target(target_name, target_options = {}) ⇒ Object
- #target_options ⇒ Object
- #trial_court ⇒ Object
- #validate(*args, &block) ⇒ Object
- #validates_with(*args, &block) ⇒ Object
Instance Attribute Details
#validators ⇒ Object
23 24 25 |
# File 'lib/rest_my_case/validator.rb', line 23 def validators @validators ||= Hash.new { |hash, key| hash[key] = [] } end |
Instance Method Details
#target(target_name, target_options = {}) ⇒ Object
18 19 20 21 |
# File 'lib/rest_my_case/validator.rb', line 18 def target(target_name, = {}) = || {} [:name] = target_name end |
#target_options ⇒ Object
14 15 16 |
# File 'lib/rest_my_case/validator.rb', line 14 def || Helpers.super_method(self, :target_options) end |
#trial_court ⇒ Object
9 10 11 12 |
# File 'lib/rest_my_case/validator.rb', line 9 def trial_court @trial_court ||= Trial::Court.new \ Judge::Base, DefenseAttorney::Base, Validator, Context::Base end |
#validate(*args, &block) ⇒ Object
27 28 29 |
# File 'lib/rest_my_case/validator.rb', line 27 def validate(*args, &block) validators[nil] << AccusationAttorneys::Custom.new(args, &block) end |
#validates_with(*args, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/rest_my_case/validator.rb', line 31 def validates_with(*args, &block) = Helpers.(args) [:class] = self args.each do |klass| store_validators_by_attribute klass.new(, &block) end end |