Module: ActiveCypher::Model::Core

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_cypher/model/core.rb

Overview

Core: The module that tries to make your graph model feel like it belongs in a relational world. Includes every concern under the sun, because why have one abstraction when you can have twelve? Most of this works thanks to a little Ruby sorcery, a dash of witchcraft, and—on rare occasions—some unexplained back magick.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#new_recordObject (readonly)

Returns the value of attribute new_record.



25
26
27
# File 'lib/active_cypher/model/core.rb', line 25

def new_record
  @new_record
end

Instance Method Details

#initialize(attributes = {}) ⇒ Object

Note:

If this works and you can’t explain why, it’s probably back magick.

Initializes a new model instance, because every object deserves a fresh start (and a fresh set of existential crises).

Parameters:

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

    Attributes to assign to the new instance



31
32
33
34
35
36
37
38
# File 'lib/active_cypher/model/core.rb', line 31

def initialize(attributes = {})
  _run(:initialize) do # <-- callback wrapper
    super()
    assign_attributes(attributes.symbolize_keys) if attributes
    @new_record = true # Always true for normal initialization, because innocence is fleeting
    clear_changes_information
  end
end