Class: Deviant::Client
- Inherits:
-
Object
- Object
- Deviant::Client
- Defined in:
- lib/deviant/client.rb
Instance Method Summary collapse
- #fetch(query, tags = []) ⇒ Object
- #index(&block) ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #search(&block) ⇒ Object
- #store(name, message, data = {}) ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
3 4 5 |
# File 'lib/deviant/client.rb', line 3 def initialize() @options = end |
Instance Method Details
#fetch(query, tags = []) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/deviant/client.rb', line 14 def fetch(query, = []) query = build_query(query) search do query { string query } filter :terms, tags: if .size > 0 sort { by :date, 'desc' } end end |
#index(&block) ⇒ Object
23 24 25 |
# File 'lib/deviant/client.rb', line 23 def index(&block) Tire.index @options[:name], &block end |
#search(&block) ⇒ Object
27 28 29 |
# File 'lib/deviant/client.rb', line 27 def search(&block) Tire.search @options[:name], &block end |
#store(name, message, data = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/deviant/client.rb', line 7 def store(name, , data = {}) entry = {name: name, message: , date: Time.now}.merge(data) return store_async(entry) if @options[:sidekiq][:enabled] index { store(entry) } end |