Class: ElasticSearch::Request
- Inherits:
-
Object
- Object
- ElasticSearch::Request
- Defined in:
- lib/elastic_search/request.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #parameters ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
5 6 7 8 9 10 11 12 13 |
# File 'lib/elastic_search/request.rb', line 5 def initialize( = {}) @method = [:method] ? [:method].to_sym : :get @index = [:index] @type = [:type] @id = [:id] @action = [:action] @parameters = [:parameters] @body = [:body] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/elastic_search/request.rb', line 3 def action @action end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/elastic_search/request.rb', line 3 def id @id end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
3 4 5 |
# File 'lib/elastic_search/request.rb', line 3 def index @index end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/elastic_search/request.rb', line 3 def method @method end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/elastic_search/request.rb', line 3 def type @type end |
Instance Method Details
#body ⇒ Object
22 23 24 |
# File 'lib/elastic_search/request.rb', line 22 def body @encoded_body ||= @body.is_a?(String) ? @body : @body.to_json end |
#parameters ⇒ Object
15 16 17 18 19 20 |
# File 'lib/elastic_search/request.rb', line 15 def parameters @stringified_parameters ||= @parameters.inject({}) do |, (key, value)| [key.to_s] = value.to_s end if @parameters end |
#path ⇒ Object
26 27 28 29 30 |
# File 'lib/elastic_search/request.rb', line 26 def path components = [@index, @type, @id] components << "_#{@action.to_s}" if @action "/#{components.compact.join("/")}" end |