Module: Neo4j::Shared::Attributes
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::AttributeMethods
- Included in:
- TypecastedAttributes
- Defined in:
- lib/neo4j/shared/attributes.rb
Overview
Attributes provides a set of class methods for defining an attributes schema and instance methods for reading and writing attributes.
Originally part of ActiveAttr, github.com/cgriego/active_attr
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- DEPRECATED_OBJECT_METHODS =
Methods deprecated on the Object class which can be safely overridden
%w(id type)
Instance Method Summary collapse
-
#==(other) ⇒ true, false
Performs equality checking on the result of attributes and its type.
-
#attributes ⇒ Hash{String => Object}
Returns a Hash of all attributes.
- #query_attribute(name) ⇒ Object
-
#write_attribute(name, value) ⇒ Object
(also: #[]=)
Write a single attribute to the model’s attribute hash.
Instance Method Details
#==(other) ⇒ true, false
Performs equality checking on the result of attributes and its type.
37 38 39 40 |
# File 'lib/neo4j/shared/attributes.rb', line 37 def ==(other) return false unless other.instance_of? self.class attributes == other.attributes end |
#attributes ⇒ Hash{String => Object}
Returns a Hash of all attributes
48 49 50 |
# File 'lib/neo4j/shared/attributes.rb', line 48 def attributes attributes_map { |name| send name } end |
#query_attribute(name) ⇒ Object
70 71 72 73 74 |
# File 'lib/neo4j/shared/attributes.rb', line 70 def query_attribute(name) fail Neo4j::UnknownAttributeError, "unknown attribute: #{name}" if !respond_to? "#{name}?" send "#{name}?" end |
#write_attribute(name, value) ⇒ Object Also known as: []=
Write a single attribute to the model’s attribute hash.
63 64 65 66 67 |
# File 'lib/neo4j/shared/attributes.rb', line 63 def write_attribute(name, value) fail Neo4j::UnknownAttributeError, "unknown attribute: #{name}" if !respond_to? "#{name}=" send "#{name}=", value end |