module Neo4j::ActiveNode::IdProperty::ClassMethods

Attributes

manual_id_property[RW]

Public Instance Methods

ensure_id_property_info!() click to toggle source

Since there's no way to know when a class is done being described, we wait until the id_property information is requested and use that as the opportunity to set up the defaults if no others are specified

    # File lib/neo4j/active_node/id_property.rb
178 def ensure_id_property_info!
179   if !manual_id_property? && !@id_property_info
180     name, type, value = id_property_name_type_value
181     id_property(name, type => value)
182   end
183 
184   handle_model_schema!
185 end
find_by_id(id) click to toggle source
    # File lib/neo4j/active_node/id_property.rb
133 def find_by_id(id)
134   all.where(id_property_name => id).first
135 end
find_by_ids(ids) click to toggle source
    # File lib/neo4j/active_node/id_property.rb
137 def find_by_ids(ids)
138   all.where(id_property_name => ids).to_a
139 end
find_by_neo_id(id) click to toggle source
    # File lib/neo4j/active_node/id_property.rb
129 def find_by_neo_id(id)
130   find_by(neo_id: id)
131 end
has_id_property?() click to toggle source

rubocop:disable Naming/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 = {}, inherited = false) click to toggle source
    # File lib/neo4j/active_node/id_property.rb
141 def id_property(name, conf = {}, inherited = false)
142   self.manual_id_property = true
143 
144   @id_property_info = {name: name, type: conf, inherited: inherited}
145   TypeMethods.define_id_methods(self, name, conf)
146 end
id_property?() click to toggle source

rubocop:enable Naming/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   ensure_id_property_info!
162 
163   @id_property_info ||= {}
164 end
id_property_name() click to toggle source
    # File lib/neo4j/active_node/id_property.rb
166 def id_property_name
167   id_property_info[:name]
168 end
Also aliased as: primary_key
manual_id_property?() click to toggle source
    # File lib/neo4j/active_node/id_property.rb
170 def manual_id_property?
171   !!manual_id_property
172 end
primary_key()
Alias for: id_property_name

Private Instance Methods

handle_model_schema!() click to toggle source
    # File lib/neo4j/active_node/id_property.rb
189 def handle_model_schema!
190   id_property_name = @id_property_info[:name]
191 
192   return if id_property_name == :neo_id || @id_property_info[:inherited]
193 
194   if @id_property_info[:type][:constraint] == false &&
195      !@id_property_info[:warned_of_constraint]
196     @id_property_info[:warned_of_constraint] = true
197     warn_constraint_option_false!(id_property_name)
198     return
199   end
200 
201   Neo4j::ModelSchema.add_defined_constraint(self, id_property_name)
202 end
id_property_name_type_value() click to toggle source
    # File lib/neo4j/active_node/id_property.rb
211 def id_property_name_type_value
212   name, type, value = Neo4j::Config.to_hash.values_at('id_property', 'id_property_type', 'id_property_type_value')
213 
214   unless name == :neo_id || (name && type && value)
215     name = :uuid
216     type = :auto
217     value = :uuid
218   end
219 
220   [name, type, value]
221 end
warn_constraint_option_false!(id_property_name) click to toggle source
    # File lib/neo4j/active_node/id_property.rb
204       def warn_constraint_option_false!(id_property_name)
205         Neo4j::ActiveBase.logger.warn <<MSG
206         WARNING: The constraint option for id_property is no longer supported (Used on #{self.name}.#{id_property_name}).
207         Since you specified `constraint: false` this option can simply be removed.
208 MSG
209       end