Module: Neo4j::ActiveRel::Property::ClassMethods

Includes:
Shared::Cypher::CreateMethod
Defined in:
lib/neo4j/active_rel/property.rb

Instance Method Summary collapse

Methods included from Shared::Cypher::CreateMethod

#create_method, #creates_unique, #creates_unique?, #creates_unique_option

Instance Method Details

#extract_association_attributes!(attributes) ⇒ Object

Extracts keys from attributes hash which are relationships of the model TODO: Validate separately that relationships are getting the right values? Perhaps also store the values and persist relationships on save?



44
45
46
47
48
49
50
51
# File 'lib/neo4j/active_rel/property.rb', line 44

def extract_association_attributes!(attributes)
  return if attributes.blank?
  {}.tap do |relationship_props|
    attributes.each_key do |key|
      relationship_props[key] = attributes.delete(key) if [:from_node, :to_node].include?(key)
    end
  end
end

#id_property_nameObject



53
54
55
# File 'lib/neo4j/active_rel/property.rb', line 53

def id_property_name
  false
end

#load_entity(id) ⇒ Object



79
80
81
# File 'lib/neo4j/active_rel/property.rb', line 79

def load_entity(id)
  Neo4j::Node.load(id)
end

#valid_class_argument?(class_argument) ⇒ Boolean

Returns:



71
72
73
74
# File 'lib/neo4j/active_rel/property.rb', line 71

def valid_class_argument?(class_argument)
  [String, Symbol, FalseClass].include?(class_argument.class) ||
    (class_argument.is_a?(Array) && class_argument.all? { |c| [String, Symbol].include?(c.class) })
end