lib/neo4j/shared/attributes.rb in neo4j-7.2.3 vs lib/neo4j/shared/attributes.rb in neo4j-8.0.0.alpha.1
- old
+ new
@@ -59,24 +59,20 @@
# @param [String, Symbol, #to_s] name The name of the attribute to update.
# @param [Object] value The value to set for the attribute.
#
# @raise [UnknownAttributeError] if the attribute is unknown
def write_attribute(name, value)
- if respond_to? "#{name}="
- send "#{name}=", value
- else
- fail Neo4j::UnknownAttributeError, "unknown attribute: #{name}"
- end
+ fail Neo4j::UnknownAttributeError, "unknown attribute: #{name}" if !respond_to? "#{name}="
+
+ send "#{name}=", value
end
- alias_method :[]=, :write_attribute
+ alias []= write_attribute
def query_attribute(name)
- if respond_to? "#{name}?"
- send "#{name}?"
- else
- fail Neo4j::UnknownAttributeError, "unknown attribute: #{name}"
- end
+ fail Neo4j::UnknownAttributeError, "unknown attribute: #{name}" if !respond_to? "#{name}?"
+
+ send "#{name}?"
end
private
# Read an attribute from the attributes hash
@@ -124,14 +120,12 @@
# @raise [DangerousAttributeError] if the attribute name conflicts with
# existing methods
#
# @return [AttributeDefinition] Attribute's definition
def attribute(name)
- if dangerous_attribute?(name)
- fail Neo4j::DangerousAttributeError, %(an attribute method named "#{name}" would conflict with an existing method)
- else
- attribute!(name)
- end
+ fail Neo4j::DangerousAttributeError, %(an attribute method named "#{name}" would conflict with an existing method) if dangerous_attribute?(name)
+
+ attribute!(name)
end
# Returns an Array of attribute names as Strings
#
# @example Get attribute names