Module: Interdependence::Model::ClassMethods
- Defined in:
- lib/interdependence/model.rb
Overview
Class methods mixed into any class that includes ‘ActiveModel::Model`
Instance Method Summary collapse
-
#clear_dependencies! ⇒ Void
private
adds an observer that expects #update_validators to be called.
-
#inherited(base) ⇒ undefined
private
Clone ‘validate_calls` on class inherited by class.
-
#update_validators ⇒ Void
private
Update validators attached to the current model.
Instance Method Details
#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.
adds an observer that expects #update_validators to be called
49 50 51 52 |
# File 'lib/interdependence/model.rb', line 49 def clear_dependencies! super dependencies.add_observer(self, :update_validators) 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.
Clone ‘validate_calls` on class inherited by class
17 18 19 20 21 |
# File 'lib/interdependence/model.rb', line 17 def inherited(base) super base.validate_calls = validate_calls.clone end |
#update_validators ⇒ 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.
Update validators attached to the current model
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/interdependence/model.rb', line 31 def update_validators(*) clear_validators! validate_calls.each do |args, _| active_model_validate(*args) end dependency_chain.each do |validator| active_model_validates_with(*validator.to_active_model) end end |