Module: Rapid::Setting::NestedValidations::ClassMethods
- Defined in:
- lib/rapid/setting/nested_validations.rb
Instance Method Summary collapse
- #nested_validation(validation, attribute, options = {}) ⇒ Object
- #nested_validations(validation, attributes, options = {}) ⇒ Object
- #validates_exclusion_of_with_nesting(*args) ⇒ Object
- #validates_format_of_with_nesting(*args) ⇒ Object
- #validates_inclusion_of_with_nesting(*args) ⇒ Object
- #validates_length_of_with_nesting(*args) ⇒ Object
- #validates_presence_of_with_nesting(*args) ⇒ Object
- #validates_size_of_with_nesting(*args) ⇒ Object
Instance Method Details
#nested_validation(validation, attribute, options = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rapid/setting/nested_validations.rb', line 62 def nested_validation validation, attribute, = {} names = attribute.to_s.split('.') name = names.pop if names.empty? send "#{validation}_without_nesting", attribute, return end namespace = setting.find_namespace *names klass = namespace.instance_class if namespace if klass.nil? raise UnknownSettingError.new(attribute) end klass.send validation, name, end |
#nested_validations(validation, attributes, options = {}) ⇒ Object
56 57 58 59 60 |
# File 'lib/rapid/setting/nested_validations.rb', line 56 def nested_validations validation, attributes, = {} attributes.each do |attribute| nested_validation validation, attribute, end end |
#validates_exclusion_of_with_nesting(*args) ⇒ Object
26 27 28 29 |
# File 'lib/rapid/setting/nested_validations.rb', line 26 def validates_exclusion_of_with_nesting *args = args. nested_validations :validates_exclusion_of, args, end |
#validates_format_of_with_nesting(*args) ⇒ Object
31 32 33 34 |
# File 'lib/rapid/setting/nested_validations.rb', line 31 def validates_format_of_with_nesting *args = args. nested_validations :validates_format_of, args, end |
#validates_inclusion_of_with_nesting(*args) ⇒ Object
36 37 38 39 |
# File 'lib/rapid/setting/nested_validations.rb', line 36 def validates_inclusion_of_with_nesting *args = args. nested_validations :validates_inclusion_of, args, end |
#validates_length_of_with_nesting(*args) ⇒ Object
41 42 43 44 |
# File 'lib/rapid/setting/nested_validations.rb', line 41 def validates_length_of_with_nesting *args = args. nested_validations :validates_length_of, args, end |
#validates_presence_of_with_nesting(*args) ⇒ Object
46 47 48 49 |
# File 'lib/rapid/setting/nested_validations.rb', line 46 def validates_presence_of_with_nesting *args = args. nested_validations :validates_presence_of, args, end |
#validates_size_of_with_nesting(*args) ⇒ Object
51 52 53 54 |
# File 'lib/rapid/setting/nested_validations.rb', line 51 def validates_size_of_with_nesting *args = args. nested_validations :validates_size_of, args, end |