Module: Neo4j::Shared::Validations
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Validations
- Included in:
- ActiveNode::Validations, ActiveRel::Validations
- Defined in:
- lib/neo4j/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/neo4j/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/neo4j/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/neo4j/shared/validations.rb', line 22 def valid?(context = nil) context ||= (new_record? ? :create : :update) super(context) errors.empty? end |