Class: Neo4j::Shared::DeclaredProperty
- Inherits:
-
Object
- Object
- Neo4j::Shared::DeclaredProperty
- Includes:
- Comparable, Index
- Defined in:
- lib/neo4j/shared/declared_property.rb,
lib/neo4j/shared/declared_property/index.rb
Overview
Contains methods related to the management
Defined Under Namespace
Modules: Index Classes: IllegalPropertyError
Constant Summary collapse
- ILLEGAL_PROPS =
%w(from_node to_node start_node end_node)
Instance Attribute Summary collapse
-
#magic_typecaster ⇒ Object
readonly
Returns the value of attribute magic_typecaster.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_string ⇒ Object
readonly
Returns the value of attribute name_string.
-
#name_sym ⇒ Object
readonly
Returns the value of attribute name_sym.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#<=>(other) ⇒ -1, ...
Compare attribute definitions.
- #[](key) ⇒ Object
- #default_value ⇒ Object (also: #default)
- #fail_invalid_options! ⇒ Object
-
#initialize(name, options = {}) ⇒ DeclaredProperty
constructor
A new instance of DeclaredProperty.
- #inspect ⇒ Object
- #register ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
- #type ⇒ Object
- #typecaster ⇒ Object
Methods included from Index
#constraint!, #constraint?, #index!, #index?, #index_or_constraint?, #unconstraint!, #unindex!
Constructor Details
#initialize(name, options = {}) ⇒ DeclaredProperty
Returns a new instance of DeclaredProperty.
12 13 14 15 16 17 18 19 |
# File 'lib/neo4j/shared/declared_property.rb', line 12 def initialize(name, = {}) fail IllegalPropertyError, "#{name} is an illegal property" if ILLEGAL_PROPS.include?(name.to_s) fail TypeError, "can't convert #{name.class} into Symbol" unless name.respond_to?(:to_sym) @name = @name_sym = name.to_sym @name_string = name.to_s @options = end |
Instance Attribute Details
#magic_typecaster ⇒ Object (readonly)
Returns the value of attribute magic_typecaster.
10 11 12 |
# File 'lib/neo4j/shared/declared_property.rb', line 10 def magic_typecaster @magic_typecaster end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/neo4j/shared/declared_property.rb', line 10 def name @name end |
#name_string ⇒ Object (readonly)
Returns the value of attribute name_string.
10 11 12 |
# File 'lib/neo4j/shared/declared_property.rb', line 10 def name_string @name_string end |
#name_sym ⇒ Object (readonly)
Returns the value of attribute name_sym.
10 11 12 |
# File 'lib/neo4j/shared/declared_property.rb', line 10 def name_sym @name_sym end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/neo4j/shared/declared_property.rb', line 10 def @options end |
Instance Method Details
#<=>(other) ⇒ -1, ...
Compare attribute definitions
30 31 32 33 34 |
# File 'lib/neo4j/shared/declared_property.rb', line 30 def <=>(other) return nil unless other.instance_of? self.class return nil if name == other.name && != other. self.to_s <=> other.to_s end |
#[](key) ⇒ Object
50 51 52 |
# File 'lib/neo4j/shared/declared_property.rb', line 50 def [](key) respond_to?(key) ? public_send(key) : nil end |
#default_value ⇒ Object Also known as: default
66 67 68 |
# File 'lib/neo4j/shared/declared_property.rb', line 66 def default_value [:default] end |
#fail_invalid_options! ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/neo4j/shared/declared_property.rb', line 71 def case when index?(:exact) && constraint?(:unique) fail Neo4j::InvalidPropertyOptionsError, "#Uniqueness constraints also provide exact indexes, cannot set both options on property #{name}" end end |
#inspect ⇒ Object
36 37 38 39 40 |
# File 'lib/neo4j/shared/declared_property.rb', line 36 def inspect = .map { |key, value| "#{key.inspect} => #{value.inspect}" }.sort.join(', ') = ", #{}" unless .empty? "attribute :#{name}#{}" end |
#register ⇒ Object
54 55 56 |
# File 'lib/neo4j/shared/declared_property.rb', line 54 def register register_magic_properties end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/neo4j/shared/declared_property.rb', line 42 def to_s name.to_s end |
#to_sym ⇒ Object
46 47 48 |
# File 'lib/neo4j/shared/declared_property.rb', line 46 def to_sym name end |
#type ⇒ Object
58 59 60 |
# File 'lib/neo4j/shared/declared_property.rb', line 58 def type [:type] end |
#typecaster ⇒ Object
62 63 64 |
# File 'lib/neo4j/shared/declared_property.rb', line 62 def typecaster [:typecaster] end |