Module: ActiveGraph::Shared::Validations
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Validations
- Included in:
- Node::Validations, Relationship::Validations
- Defined in:
- lib/active_graph/shared/validations.rb
Instance Method Summary collapse
-
#read_attribute_for_validation(key) ⇒ Object
Implements the ActiveModel::Validation hook method.
-
#save(options = {}) ⇒ Boolean
The validation process on save can be skipped by passing false.
-
#valid?(context = nil) ⇒ Boolean
True if valid.
Instance Method Details
#read_attribute_for_validation(key) ⇒ Object
Implements the ActiveModel::Validation hook method.
8 9 10 |
# File 'lib/active_graph/shared/validations.rb', line 8 def read_attribute_for_validation(key) respond_to?(key) ? send(key) : self[key] end |
#save(options = {}) ⇒ Boolean
The validation process on save can be skipped by passing false. The regular Model#save method is replaced with this when the validations module is mixed in, which it is by default.
17 18 19 |
# File 'lib/active_graph/shared/validations.rb', line 17 def save( = {}) perform_validations() ? super : false end |
#valid?(context = nil) ⇒ Boolean
Returns true if valid.
22 23 24 25 26 |
# File 'lib/active_graph/shared/validations.rb', line 22 def valid?(context = nil) context ||= (new_record? ? :create : :update) super(context) errors.empty? end |