Class: Neo4j::Core::Index::IndexConfig
- Inherits:
-
Object
- Object
- Neo4j::Core::Index::IndexConfig
- Defined in:
- lib/neo4j-core/index/index_config.rb
Overview
Responsible for holding the configuration for one index Is used in a DSL to configure the index.
Instance Attribute Summary (collapse)
-
- (Object) _field_types
readonly
Returns the value of attribute _field_types.
-
- (Object) _index_names
readonly
Returns the value of attribute _index_names.
-
- (Object) _index_type
readonly
Returns the value of attribute _index_type.
-
- (Object) _trigger_on
readonly
Returns the value of attribute _trigger_on.
-
- (Object) entity_type
readonly
Returns the value of attribute entity_type.
Instance Method Summary (collapse)
- - (Object) _prefix_index_name
-
- (Class?) decl_type_on(prop)
The specified type of the property or nil.
- - (Object) field_type(key)
- - (Object) fields
- - (Boolean) has_index_type?(type)
-
- (Object) index(args)
Specifies an index with configuration Used in the Index DSL.
- - (Boolean) index?(field)
-
- (Object) index_name_for_type(type)
The index name for the lucene index given a type.
- - (Object) index_names(hash)
- - (Object) index_type(field)
- - (Object) inherit_from(clazz)
-
- (IndexConfig) initialize(entity_type)
constructor
A new instance of IndexConfig.
- - (Boolean) numeric?(field)
-
- (Object) prefix_index_name(&block)
Defines the.
- - (Object) rm_index_config
- - (Object) to_s
-
- (Object) trigger_on(hash)
Specifies which property and values the index should be triggered on.
-
- (true, false) trigger_on?(props)
If the props can/should trigger an index operation.
Constructor Details
- (IndexConfig) initialize(entity_type)
A new instance of IndexConfig
11 12 13 14 15 16 |
# File 'lib/neo4j-core/index/index_config.rb', line 11 def initialize(entity_type) @entity_type = entity_type @_index_type = {} @_field_types = {} @_trigger_on = {} end |
Instance Attribute Details
- (Object) _field_types (readonly)
Returns the value of attribute _field_types
8 9 10 |
# File 'lib/neo4j-core/index/index_config.rb', line 8 def _field_types @_field_types end |
- (Object) _index_names (readonly)
Returns the value of attribute _index_names
8 9 10 |
# File 'lib/neo4j-core/index/index_config.rb', line 8 def _index_names @_index_names end |
- (Object) _index_type (readonly)
Returns the value of attribute _index_type
8 9 10 |
# File 'lib/neo4j-core/index/index_config.rb', line 8 def _index_type @_index_type end |
- (Object) _trigger_on (readonly)
Returns the value of attribute _trigger_on
8 9 10 |
# File 'lib/neo4j-core/index/index_config.rb', line 8 def _trigger_on @_trigger_on end |
- (Object) entity_type (readonly)
Returns the value of attribute entity_type
8 9 10 |
# File 'lib/neo4j-core/index/index_config.rb', line 8 def entity_type @entity_type end |
Instance Method Details
- (Object) _prefix_index_name
74 75 76 |
# File 'lib/neo4j-core/index/index_config.rb', line 74 def _prefix_index_name @prefix_index_name_block.nil? ? "" : @prefix_index_name_block.call end |
- (Class?) decl_type_on(prop)
The specified type of the property or nil
55 56 57 |
# File 'lib/neo4j-core/index/index_config.rb', line 55 def decl_type_on(prop) @_field_types[prop] end |
- (Object) field_type(key)
36 37 38 |
# File 'lib/neo4j-core/index/index_config.rb', line 36 def field_type(key) @_field_types[key.to_s] end |
- (Object) fields
95 96 97 |
# File 'lib/neo4j-core/index/index_config.rb', line 95 def fields @_index_type.keys end |
- (Boolean) has_index_type?(type)
91 92 93 |
# File 'lib/neo4j-core/index/index_config.rb', line 91 def has_index_type?(type) @_index_type.values.include?(type) end |
- (Object) index(args)
Specifies an index with configuration Used in the Index DSL.
44 45 46 47 48 49 50 51 |
# File 'lib/neo4j-core/index/index_config.rb', line 44 def index(args) conf = args.last.kind_of?(Hash) ? args.pop : {} args.uniq.each do |field| @_index_type[field.to_s] = conf[:type] || :exact @_field_types[field.to_s] = conf[:field_type] || String end end |
- (Boolean) index?(field)
99 100 101 |
# File 'lib/neo4j-core/index/index_config.rb', line 99 def index?(field) @_index_type.include?(field.to_s) end |
- (Object) index_name_for_type(type)
The index name for the lucene index given a type
65 66 67 |
# File 'lib/neo4j-core/index/index_config.rb', line 65 def index_name_for_type(type) _prefix_index_name + @_index_names[type] end |
- (Object) index_names(hash)
78 79 80 |
# File 'lib/neo4j-core/index/index_config.rb', line 78 def index_names(hash) @_index_names = hash end |
- (Object) index_type(field)
87 88 89 |
# File 'lib/neo4j-core/index/index_config.rb', line 87 def index_type(field) @_index_type[field.to_s] end |
- (Object) inherit_from(clazz)
22 23 24 25 26 27 |
# File 'lib/neo4j-core/index/index_config.rb', line 22 def inherit_from(clazz) c = clazz._indexer.config raise "Can't inherit from different index type #{@entity_type} != #{c.entity_type}" if @entity_type != c.entity_type @_index_type.merge!(c._index_type) @_field_types.merge!(c._field_types) end |
- (Boolean) numeric?(field)
103 104 105 106 |
# File 'lib/neo4j-core/index/index_config.rb', line 103 def numeric?(field) raise "No index on #{field.inspect}, has fields: #{@field_types.inspect}" unless @_field_types[field] @_field_types[field] != String end |
- (Object) prefix_index_name(&block)
Defines the
70 71 72 |
# File 'lib/neo4j-core/index/index_config.rb', line 70 def prefix_index_name(&block) @prefix_index_name_block = block end |
- (Object) rm_index_config
82 83 84 85 |
# File 'lib/neo4j-core/index/index_config.rb', line 82 def rm_index_config @_index_type = {} @_field_types = {} end |
- (Object) to_s
18 19 20 |
# File 'lib/neo4j-core/index/index_config.rb', line 18 def to_s "IndexConfig [#@entity_type, _index_type: #{@_index_type.inspect}, _field_types: #{@_field_types.inspect}, _trigger_on: #{@_trigger_on.inspect}]" end |
- (Object) trigger_on(hash)
Specifies which property and values the index should be triggered on. Used in the Index DSL.
32 33 34 |
# File 'lib/neo4j-core/index/index_config.rb', line 32 def trigger_on(hash) merge_and_to_string(@_trigger_on, hash) end |
- (true, false) trigger_on?(props)
If the props can/should trigger an index operation
60 61 62 |
# File 'lib/neo4j-core/index/index_config.rb', line 60 def trigger_on?(props) @_trigger_on.each_pair { |k, v| break true if (a = props[k]) && (v.include?(a)) } == true end |