Class: Esse::Index::RequestConfigurable::RequestParams
- Inherits:
-
Object
- Object
- Esse::Index::RequestConfigurable::RequestParams
- Defined in:
- lib/esse/index/request_configurable.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
Instance Method Summary collapse
-
#call(doc) ⇒ Hash
The request parameters for the operation.
-
#initialize(operation, hash = {}, &block) ⇒ RequestParams
constructor
A new instance of RequestParams.
Constructor Details
#initialize(operation, hash = {}, &block) ⇒ RequestParams
Returns a new instance of RequestParams.
21 22 23 24 25 |
# File 'lib/esse/index/request_configurable.rb', line 21 def initialize(operation, hash = {}, &block) @operation = operation @hash = hash.transform_keys(&:to_sym) @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
19 20 21 |
# File 'lib/esse/index/request_configurable.rb', line 19 def block @block end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
19 20 21 |
# File 'lib/esse/index/request_configurable.rb', line 19 def hash @hash end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
19 20 21 |
# File 'lib/esse/index/request_configurable.rb', line 19 def operation @operation end |
Instance Method Details
#call(doc) ⇒ Hash
Returns the request parameters for the operation.
30 31 32 33 34 35 36 37 |
# File 'lib/esse/index/request_configurable.rb', line 30 def call(doc) return hash unless block result = block.call(doc) || {} raise ArgumentError, "Expected a Hash, got #{result.class}" unless result.is_a?(Hash) hash.merge(result.transform_keys(&:to_sym)) end |