DeclaredProperty

Contains methods related to the management

Constants

  • ILLEGAL_PROPS

Methods

#constraint!

def constraint!(type = :unique)
  fail Neo4j::InvalidPropertyOptionsError, "Unable to set constraint on indexed property #{name}" if index?(:exact)
  options[:constraint] = type
end

#constraint?

def constraint?(type = :unique)
  options.key?(:constraint) && options[:constraint] == type
end

#default_value

def default_value
  options[:default]
end

#fail_invalid_options!

def fail_invalid_options!
  case
  when index?(:exact) && constraint?(:unique)
    fail Neo4j::InvalidPropertyOptionsError,
         "#Uniqueness constraints also provide exact indexes, cannot set both options on property #{name}"
  end
end

#index!

def index!(type = :exact)
  fail Neo4j::InvalidPropertyOptionsError, "Unable to set index on constrainted property #{name}" if constraint?(:unique)
  options[:index] = type
end

#index?

def index?(type = :exact)
  options.key?(:index) && options[:index] == type
end

#index_or_constraint?

def index_or_constraint?
  index?(:exact) || constraint?(:unique)
end

#initialize

def initialize(name, options = {})
  fail IllegalPropertyError, "#{name} is an illegal property" if ILLEGAL_PROPS.include?(name.to_s)
  @name = @name_sym = name
  @name_string = name.to_s
  @options = options
  fail_invalid_options!
end
#magic_typecaster

Returns the value of attribute magic_typecaster

def magic_typecaster
  @magic_typecaster
end
#name

Returns the value of attribute name

def name
  @name
end
#name_string

Returns the value of attribute name_string

def name_string
  @name_string
end
#name_sym

Returns the value of attribute name_sym

def name_sym
  @name_sym
end
#options

Returns the value of attribute options

def options
  @options
end

#register

def register
  register_magic_properties
end

#type

def type
  options[:type]
end

#typecaster

def typecaster
  options[:typecaster]
end

#unconstraint!

def unconstraint!(type = :unique)
  options.delete(:constraint) if constraint?(type)
end

#unindex!

def unindex!(type = :exact)
  options.delete(:index) if index?(type)
end