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

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.

Parameters:

  • options (Hash) (defaults to: {})

    the options to create a message with.

Options Hash (options):

  • :validate (true, false)

    if false no validation will take place

Returns:

  • (Boolean)

    true if it saved it successfully



17
18
19
# File 'lib/neo4j/shared/validations.rb', line 17

def save(options = {})
  perform_validations(options) ? super : false
end

#valid?(context = nil) ⇒ Boolean

Returns true if valid.

Returns:



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