Class: Ashikawa::Core::Index
- Inherits:
-
Object
- Object
- Ashikawa::Core::Index
- Defined in:
- lib/ashikawa-core/index.rb
Overview
An index on a certain collection
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The ID of the index (includes a Collection prefix).
-
#on ⇒ Array<Symbol>
readonly
The fields the index is defined on as symbols.
-
#type ⇒ Symbol
readonly
The type of index as a symbol.
-
#unique ⇒ Boolean
readonly
Is the unique constraint set?.
Instance Method Summary collapse
-
#delete ⇒ Hash
Remove the index from the collection.
-
#initialize(collection, raw_index) ⇒ Index
constructor
Create a new Index.
Constructor Details
#initialize(collection, raw_index) ⇒ Index
Create a new Index
54 55 56 57 58 59 60 |
# File 'lib/ashikawa-core/index.rb', line 54 def initialize(collection, raw_index) @collection = collection @id = raw_index['id'] @on = convert_to_symbols(raw_index['fields']) @type = raw_index['type'].to_sym @unique = raw_index['unique'] end |
Instance Attribute Details
#id ⇒ String (readonly)
The ID of the index (includes a Collection prefix)
44 45 46 |
# File 'lib/ashikawa-core/index.rb', line 44 def id @id end |
#on ⇒ Array<Symbol> (readonly)
The fields the index is defined on as symbols
17 18 19 |
# File 'lib/ashikawa-core/index.rb', line 17 def on @on end |
#type ⇒ Symbol (readonly)
The type of index as a symbol
26 27 28 |
# File 'lib/ashikawa-core/index.rb', line 26 def type @type end |
#unique ⇒ Boolean (readonly)
Is the unique constraint set?
35 36 37 |
# File 'lib/ashikawa-core/index.rb', line 35 def unique @unique end |
Instance Method Details
#delete ⇒ Hash
Remove the index from the collection
69 70 71 |
# File 'lib/ashikawa-core/index.rb', line 69 def delete @collection.send_request("index/#{@id}", delete: {}) end |