Class: IndexTanked::IndexTank::Function
- Inherits:
-
Object
- Object
- IndexTanked::IndexTank::Function
- Defined in:
- lib/index-tanked/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.
8 9 10 11 12 13 14 15 16 |
# File 'lib/index-tanked/indextank/function.rb', line 8 def initialize(function_url, index, definition) @uri = "#{function_url}/#{index}" @index = index @definition = definition @conn = IndexTanked::IndexTank.setup_connection(@uri) do |faraday| # Function and Document have the same Response statuses faraday.use IndexTanked::IndexTank::DocumentResponseMiddleware end end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
6 7 8 |
# File 'lib/index-tanked/indextank/function.rb', line 6 def definition @definition end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/index-tanked/indextank/function.rb', line 6 def index @index end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/index-tanked/indextank/function.rb', line 6 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 42 43 |
# File 'lib/index-tanked/indextank/function.rb', line 39 def ==(other) self.uri == other.uri and self.index == other.index self.definition == other.definition end |
#add(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/index-tanked/indextank/function.rb', line 18 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
30 31 32 33 34 35 36 37 |
# File 'lib/index-tanked/indextank/function.rb', line 30 def delete( = {}) resp = @conn.delete do |req| req.url '' req.body = .to_json end true end |