Module: Neo4j::ActiveNode::IdProperty::ClassMethods

Defined in:
lib/neo4j/active_node/id_property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#manual_id_propertyObject

Returns the value of attribute manual_id_property.



125
126
127
# File 'lib/neo4j/active_node/id_property.rb', line 125

def manual_id_property
  @manual_id_property
end

Instance Method Details

#find_by_id(id) ⇒ Object



131
132
133
# File 'lib/neo4j/active_node/id_property.rb', line 131

def find_by_id(id)
  all.where(id_property_name => id).first
end

#find_by_ids(ids) ⇒ Object



135
136
137
# File 'lib/neo4j/active_node/id_property.rb', line 135

def find_by_ids(ids)
  all.where(id_property_name => ids).to_a
end

#find_by_neo_id(id) ⇒ Object



127
128
129
# File 'lib/neo4j/active_node/id_property.rb', line 127

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

#has_id_property?Boolean

rubocop:disable Style/PredicateName

Returns:



149
150
151
152
153
# File 'lib/neo4j/active_node/id_property.rb', line 149

def has_id_property?
  ActiveSupport::Deprecation.warn 'has_id_property? is deprecated and may be removed from future releases, use id_property? instead.', caller

  id_property?
end

#id_property(name, conf = {}) ⇒ Object



139
140
141
142
143
144
145
146
# File 'lib/neo4j/active_node/id_property.rb', line 139

def id_property(name, conf = {})
  self.manual_id_property = true
  Neo4j::Session.on_next_session_available do |_|
    @id_property_info = {name: name, type: conf}
    TypeMethods.define_id_methods(self, name, conf)
    constraint(name, type: :unique) unless conf[:constraint] == false
  end
end

#id_property?Boolean

rubocop:enable Style/PredicateName

Returns:



156
157
158
# File 'lib/neo4j/active_node/id_property.rb', line 156

def id_property?
  id_property_info && !id_property_info.empty?
end

#id_property_infoObject



160
161
162
# File 'lib/neo4j/active_node/id_property.rb', line 160

def id_property_info
  @id_property_info ||= {}
end

#id_property_nameObject Also known as: primary_key



164
165
166
# File 'lib/neo4j/active_node/id_property.rb', line 164

def id_property_name
  id_property_info[:name]
end

#manual_id_property?Boolean

Returns:



168
169
170
# File 'lib/neo4j/active_node/id_property.rb', line 168

def manual_id_property?
  !!manual_id_property
end