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
- #validate(*args, &block) ⇒ Object
- #validates_with(*args, &block) ⇒ Object
Instance Attribute Details
#validators ⇒ Object
18 19 20 |
# File 'lib/rest_my_case/validator.rb', line 18 def validators @validators ||= Hash.new { |hash, key| hash[key] = [] } end |
Instance Method Details
#target(target_name, target_options = {}) ⇒ Object
13 14 15 16 |
# File 'lib/rest_my_case/validator.rb', line 13 def target(target_name, = {}) = || {} [:name] = target_name end |
#target_options ⇒ Object
9 10 11 |
# File 'lib/rest_my_case/validator.rb', line 9 def || Helpers.super_method(self, :target_options) end |
#validate(*args, &block) ⇒ Object
22 23 24 |
# File 'lib/rest_my_case/validator.rb', line 22 def validate(*args, &block) validators[nil] << AccusationAttorneys::Custom.new(args, &block) end |
#validates_with(*args, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/rest_my_case/validator.rb', line 26 def validates_with(*args, &block) = Helpers.(args) [:class] = self args.each do |klass| store_validators_by_attribute klass.new(, &block) end end |