Class: IndexTank::Function
- Inherits:
-
Object
- Object
- IndexTank::Function
- Defined in:
- lib/indextank/function.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add(options = {}) ⇒ Object
- #delete(options = {}) ⇒ Object
-
#initialize(function_url, index, definition) ⇒ Function
constructor
A new instance of Function.
Constructor Details
#initialize(function_url, index, definition) ⇒ Function
Returns a new instance of Function.
7 8 9 10 11 12 13 14 15 |
# File 'lib/indextank/function.rb', line 7 def initialize(function_url, index, definition) @uri = "#{function_url}/#{index}" @index = index @definition = definition @conn = IndexTank.setup_connection(@uri) do |faraday| # Function and Document have the same Response statuses faraday.use IndexTank::DocumentResponseMiddleware end end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
5 6 7 |
# File 'lib/indextank/function.rb', line 5 def definition @definition end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
5 6 7 |
# File 'lib/indextank/function.rb', line 5 def index @index end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/indextank/function.rb', line 5 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 42 |
# File 'lib/indextank/function.rb', line 38 def ==(other) self.uri == other.uri and self.index == other.index self.definition == other.definition end |
#add(options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/indextank/function.rb', line 17 def add( = {}) raise MissingFunctionDefinition unless self.definition .merge!(:definition => self.definition) response = @conn.put do |req| req.url '' req.body = .to_json end true end |
#delete(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/indextank/function.rb', line 29 def delete( = {}) resp = @conn.delete do |req| req.url '' req.body = .to_json end true end |