Class: ActiveGraph::Shared::DeclaredProperty
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveGraph::Shared::DeclaredProperty
 
 
- Includes:
 - Index, Comparable
 
- Defined in:
 - lib/active_graph/shared/declared_property.rb,
lib/active_graph/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
- 
  
    
      #default_value  ⇒ Object 
    
    
      (also: #default)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute default_value.
 - 
  
    
      #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.
 - 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute type.
 - 
  
    
      #typecaster  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute typecaster.
 
Instance Method Summary collapse
- 
  
    
      #<=>(other)  ⇒ -1, ... 
    
    
  
  
  
  
  
  
  
  
  
    
Compare attribute definitions.
 - #[](key) ⇒ Object
 - #fail_invalid_options! ⇒ Object
 - 
  
    
      #initialize(name, options = {})  ⇒ DeclaredProperty 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of DeclaredProperty.
 - #inspect ⇒ Object
 - #register ⇒ Object
 - #to_s ⇒ Object
 - #to_sym ⇒ 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.
      13 14 15 16 17 18 19 20 21 22 23  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 13 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 @type = [:type] @typecaster = [:typecaster] @default_value = [:default] @options = end  | 
  
Instance Attribute Details
#default_value ⇒ Object (readonly) Also known as: default
Returns the value of attribute default_value.
      10 11 12  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 10 def default_value @default_value end  | 
  
#magic_typecaster ⇒ Object (readonly)
Returns the value of attribute magic_typecaster.
      10 11 12  | 
    
      # File 'lib/active_graph/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/active_graph/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/active_graph/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/active_graph/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/active_graph/shared/declared_property.rb', line 10 def @options end  | 
  
#type ⇒ Object (readonly)
Returns the value of attribute type.
      10 11 12  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 10 def type @type end  | 
  
#typecaster ⇒ Object (readonly)
Returns the value of attribute typecaster.
      10 11 12  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 10 def typecaster @typecaster end  | 
  
Instance Method Details
#<=>(other) ⇒ -1, ...
Compare attribute definitions
      34 35 36 37 38  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 34 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
      54 55 56  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 54 def [](key) respond_to?(key) ? public_send(key) : nil end  | 
  
#fail_invalid_options! ⇒ Object
      62 63 64 65 66 67 68  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 62 def case when index?(:exact) && constraint?(:unique) fail ActiveGraph::InvalidPropertyOptionsError, "#Uniqueness constraints also provide exact indexes, cannot set both options on property #{name}" end end  | 
  
#inspect ⇒ Object
      40 41 42 43 44  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 40 def inspect = .map { |key, value| "#{key.inspect} => #{value.inspect}" }.sort.join(', ') = ", #{}" unless .empty? "attribute :#{name}#{}" end  | 
  
#register ⇒ Object
      58 59 60  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 58 def register register_magic_properties end  | 
  
#to_s ⇒ Object
      46 47 48  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 46 def to_s name.to_s end  | 
  
#to_sym ⇒ Object
      50 51 52  | 
    
      # File 'lib/active_graph/shared/declared_property.rb', line 50 def to_sym name end  |