module Neo4j::ActiveNode::IdProperty::ClassMethods
Attributes
manual_id_property[RW]
Public Instance Methods
find_by_id(id)
click to toggle source
# File lib/neo4j/active_node/id_property.rb 131 def find_by_id(id) 132 all.where(id_property_name => id).first 133 end
find_by_ids(ids)
click to toggle source
# File lib/neo4j/active_node/id_property.rb 135 def find_by_ids(ids) 136 all.where(id_property_name => ids).to_a 137 end
find_by_neo_id(id)
click to toggle source
# File lib/neo4j/active_node/id_property.rb 127 def find_by_neo_id(id) 128 Neo4j::Node.load(id) 129 end
has_id_property?()
click to toggle source
rubocop:disable Style/PredicateName
# File lib/neo4j/active_node/id_property.rb 149 def has_id_property? 150 ActiveSupport::Deprecation.warn 'has_id_property? is deprecated and may be removed from future releases, use id_property? instead.', caller 151 152 id_property? 153 end
id_property(name, conf = {})
click to toggle source
# File lib/neo4j/active_node/id_property.rb 139 def id_property(name, conf = {}) 140 self.manual_id_property = true 141 Neo4j::Session.on_next_session_available do |_| 142 @id_property_info = {name: name, type: conf} 143 TypeMethods.define_id_methods(self, name, conf) 144 constraint(name, type: :unique) unless conf[:constraint] == false 145 end 146 end
id_property?()
click to toggle source
rubocop:enable Style/PredicateName
# File lib/neo4j/active_node/id_property.rb 156 def id_property? 157 id_property_info && !id_property_info.empty? 158 end
id_property_info()
click to toggle source
# File lib/neo4j/active_node/id_property.rb 160 def id_property_info 161 @id_property_info ||= {} 162 end
id_property_name()
click to toggle source
# File lib/neo4j/active_node/id_property.rb 164 def id_property_name 165 id_property_info[:name] 166 end
Also aliased as: primary_key
manual_id_property?()
click to toggle source
# File lib/neo4j/active_node/id_property.rb 168 def manual_id_property? 169 !!manual_id_property 170 end
Private Instance Methods
id_property_constraint(name)
click to toggle source
# File lib/neo4j/active_node/id_property.rb 176 def id_property_constraint(name) 177 if id_property? 178 unless mapped_label.uniqueness_constraints[:property_keys].include?([name]) 179 # Neo4j Embedded throws a crazy error when a constraint can't be dropped 180 drop_constraint(id_property_name, type: :unique) if constraint?(mapped_label_name, id_property_name) 181 end 182 end 183 rescue Neo4j::Server::CypherResponse::ResponseError, Java::OrgNeo4jCypher::CypherExecutionException 184 end