Module: ActiveGraph::Node::IdProperty::ClassMethods
- Defined in:
- lib/active_graph/node/id_property.rb
Instance Attribute Summary collapse
-
#manual_id_property ⇒ Object
Returns the value of attribute manual_id_property.
Instance Method Summary collapse
-
#ensure_id_property_info! ⇒ Object
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.
- #find_by_id(id) ⇒ Object
- #find_by_ids(ids) ⇒ Object
- #find_by_neo_id(id) ⇒ Object
-
#has_id_property? ⇒ Boolean
rubocop:disable Naming/PredicateName.
- #id_property(name, conf = {}, inherited = false) ⇒ Object
-
#id_property? ⇒ Boolean
rubocop:enable Naming/PredicateName.
- #id_property_info ⇒ Object
- #id_property_name ⇒ Object (also: #primary_key)
- #manual_id_property? ⇒ Boolean
Instance Attribute Details
#manual_id_property ⇒ Object
Returns the value of attribute manual_id_property.
127 128 129 |
# File 'lib/active_graph/node/id_property.rb', line 127 def manual_id_property @manual_id_property end |
Instance Method Details
#ensure_id_property_info! ⇒ Object
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
178 179 180 181 182 183 184 185 |
# File 'lib/active_graph/node/id_property.rb', line 178 def ensure_id_property_info! if !manual_id_property? && !@id_property_info name, type, value = id_property_name_type_value id_property(name, type => value) end handle_model_schema! end |
#find_by_id(id) ⇒ Object
133 134 135 |
# File 'lib/active_graph/node/id_property.rb', line 133 def find_by_id(id) all.where(id_property_name => id).first end |
#find_by_ids(ids) ⇒ Object
137 138 139 |
# File 'lib/active_graph/node/id_property.rb', line 137 def find_by_ids(ids) all.where(id_property_name => ids).to_a end |
#find_by_neo_id(id) ⇒ Object
129 130 131 |
# File 'lib/active_graph/node/id_property.rb', line 129 def find_by_neo_id(id) find_by(neo_id: id) end |
#has_id_property? ⇒ Boolean
rubocop:disable Naming/PredicateName
149 150 151 152 153 |
# File 'lib/active_graph/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 = {}, inherited = false) ⇒ Object
141 142 143 144 145 146 |
# File 'lib/active_graph/node/id_property.rb', line 141 def id_property(name, conf = {}, inherited = false) self.manual_id_property = true @id_property_info = {name: name, type: conf, inherited: inherited} TypeMethods.define_id_methods(self, name, conf) end |
#id_property? ⇒ Boolean
rubocop:enable Naming/PredicateName
156 157 158 |
# File 'lib/active_graph/node/id_property.rb', line 156 def id_property? id_property_info && !id_property_info.empty? end |
#id_property_info ⇒ Object
160 161 162 163 164 |
# File 'lib/active_graph/node/id_property.rb', line 160 def id_property_info ensure_id_property_info! @id_property_info ||= {} end |
#id_property_name ⇒ Object Also known as: primary_key
166 167 168 |
# File 'lib/active_graph/node/id_property.rb', line 166 def id_property_name id_property_info[:name] end |
#manual_id_property? ⇒ Boolean
170 171 172 |
# File 'lib/active_graph/node/id_property.rb', line 170 def manual_id_property? !!manual_id_property end |