Module: Eson::API

Instance Method Summary collapse

Methods included from Chainable

#chainable, #extendable

Instance Method Details

#multi_index(bool) ⇒ Object



41
42
43
44
45
# File 'lib/eson/api.rb', line 41

def multi_index(bool)
  define_method :multi_index do
    bool
  end
end

#multi_types(bool) ⇒ Object



47
48
49
50
51
# File 'lib/eson/api.rb', line 47

def multi_types(bool)
  define_method :multi_types do
    bool
  end
end

#no_indices(bool) ⇒ Object



53
54
55
56
57
# File 'lib/eson/api.rb', line 53

def no_indices(bool)
  define_method :no_indices do
    bool
  end
end

#parameters(*params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/eson/api.rb', line 5

def parameters(*params)
  chainable do
    define_method :parameters do
      super() + params
    end
    
    params.each do |p|
      attr_accessor p
    end
  end
end

#register(mod) ⇒ Object



59
60
61
# File 'lib/eson/api.rb', line 59

def register(mod)
  include(mod)
end

#source_param(*params) ⇒ Object

Designates the name of the parameter that will be used as the body of the request. Use only if the API has such a parameter (e.g. Search). You still have to list this parameter.

If multiple parameters are given, they will act as the keys in the sent JSON object.

Examples:

source_param call

source_param :settings, :mappings

result

{
  "settings" : {...},
  "mappings" : {...}
}


31
32
33
34
35
36
37
38
39
# File 'lib/eson/api.rb', line 31

def source_param(*params)
  if params.length == 1
    params = params.first
  end
  
  define_method :source_param do
    params
  end
end