Class: Waistband::Index
- Inherits:
-
Object
- Object
- Waistband::Index
- Defined in:
- lib/waistband/index.rb
Instance Method Summary collapse
-
#create! ⇒ Object
create the index.
- #delete!(key) ⇒ Object
-
#destroy! ⇒ Object
destroy the index.
-
#initialize(index) ⇒ Index
constructor
A new instance of Index.
- #query(term, options = {}) ⇒ Object
- #read(key) ⇒ Object
-
#refresh ⇒ Object
refresh the index.
- #search_url ⇒ Object
- #store!(key, data) ⇒ Object
- #update_settings! ⇒ Object
Constructor Details
#initialize(index) ⇒ Index
Returns a new instance of Index.
4 5 6 7 8 |
# File 'lib/waistband/index.rb', line 4 def initialize(index) @index = index @index_name = config['name'] @stringify = config['stringify'] end |
Instance Method Details
#create! ⇒ Object
create the index
11 12 13 |
# File 'lib/waistband/index.rb', line 11 def create! connection.create! @index end |
#delete!(key) ⇒ Object
49 50 51 |
# File 'lib/waistband/index.rb', line 49 def delete!(key) connection.delete! @index, key end |
#destroy! ⇒ Object
destroy the index
16 17 18 |
# File 'lib/waistband/index.rb', line 16 def destroy! connection.destroy! @index end |
#query(term, options = {}) ⇒ Object
57 58 59 |
# File 'lib/waistband/index.rb', line 57 def query(term, = {}) ::Waistband::Query.new @index, term, end |
#read(key) ⇒ Object
53 54 55 |
# File 'lib/waistband/index.rb', line 53 def read(key) connection.read @index, key end |
#refresh ⇒ Object
refresh the index
25 26 27 |
# File 'lib/waistband/index.rb', line 25 def refresh connection.refresh @index end |
#search_url ⇒ Object
61 62 63 |
# File 'lib/waistband/index.rb', line 61 def search_url connection.search_url_for_index @index end |
#store!(key, data) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/waistband/index.rb', line 29 def store!(key, data) # map everything to strings if @stringify original_data = data if data.is_a? Array data = ::Waistband::StringifiedArray.new data elsif data.is_a? Hash data = ::Waistband::StringifiedHash.new_from data end data = data.stringify_all if data.respond_to? :stringify_all end result = connection.put @index, key, data data = original_data if @stringify result end |
#update_settings! ⇒ Object
20 21 22 |
# File 'lib/waistband/index.rb', line 20 def update_settings! connection.update_settings! @index end |