Module: Tire::DSL

Included in:
Tire
Defined in:
lib/tire/dsl.rb

Instance Method Summary collapse

Instance Method Details

#aliasesObject



38
39
40
# File 'lib/tire/dsl.rb', line 38

def aliases
  Alias.all
end

#configure(&block) ⇒ Object



4
5
6
# File 'lib/tire/dsl.rb', line 4

def configure(&block)
  Configuration.class_eval(&block)
end

#index(name, &block) ⇒ Object



30
31
32
# File 'lib/tire/dsl.rb', line 30

def index(name, &block)
  Index.new(name, &block)
end

#scan(names, options = {}, &block) ⇒ Object



34
35
36
# File 'lib/tire/dsl.rb', line 34

def scan(names, options={}, &block)
  Search::Scan.new(names, options, &block)
end

#search(indices = nil, options = {}, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tire/dsl.rb', line 8

def search(indices=nil, options={}, &block)
  if block_given?
    Search::Search.new(indices, options, &block)
  else
    payload = case options
      when Hash    then
        options
      when String  then
        Tire.warn "Passing the payload as a JSON string in Tire.search has been deprecated, " +
                   "please use the block syntax or pass a plain Hash."
        options
      else raise ArgumentError, "Please pass a Ruby Hash or String with JSON"
    end

    Search::Search.new(indices, :payload => payload)
  end
rescue Exception => error
  STDERR.puts "[REQUEST FAILED] #{error.class} #{error.message rescue nil}\n"
  raise
ensure
end