Module: Interdependence::Validator::ClassMethods
- Defined in:
- lib/interdependence/validator.rb
Overview
Class methods mixed into ActiveModel::Validator
Instance Method Summary collapse
-
#as_dependency ⇒ Dependency::Validator
private
Current validator wrapped in the Dependency::Validator class.
-
#clear_dependencies! ⇒ Void
private
Registers self as a dependency owner on dependencies.
-
#inherit_dependencies(old_owner) ⇒ undefined
private
Delete another key and inherit its dependencies.
-
#inherited(base) ⇒ undefined
private
Transfer parent dependencies to child upon inheritance.
-
#sync_dependencies ⇒ Void
private
Merges dependencies of validators the current class depends on.
Instance Method Details
#as_dependency ⇒ Dependency::Validator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Current validator wrapped in the Dependency::Validator class
38 39 40 |
# File 'lib/interdependence/validator.rb', line 38 def as_dependency @as_dependency ||= Dependency::Validator.new(validator_class: self) end |
#clear_dependencies! ⇒ Void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Registers self as a dependency owner on dependencies
61 62 63 64 |
# File 'lib/interdependence/validator.rb', line 61 def clear_dependencies! super dependencies.register(as_dependency) end |
#inherit_dependencies(old_owner) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Delete another key and inherit its dependencies
29 30 31 |
# File 'lib/interdependence/validator.rb', line 29 def inherit_dependencies(old_owner) dependencies[as_dependency] = dependencies.delete(old_owner) end |
#inherited(base) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Transfer parent dependencies to child upon inheritance
15 16 17 18 19 |
# File 'lib/interdependence/validator.rb', line 15 def inherited(base) super base.inherit_dependencies(as_dependency) end |
#sync_dependencies ⇒ Void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Merges dependencies of validators the current class depends on
48 49 50 51 52 53 |
# File 'lib/interdependence/validator.rb', line 48 def sync_dependencies(*) dependencies.keys.each do |key| validator = key.validator_class dependencies[key] = validator.dependencies[validator.as_dependency] end end |