Class: Kong::Upstream

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/kong/upstream.rb

Constant Summary collapse

ATTRIBUTE_NAMES =
%w(id name slots orderlist).freeze
API_END_POINT =
'/upstreams/'.freeze

Instance Attribute Summary

Attributes included from Base

#api_end_point, #attributes

Instance Method Summary collapse

Methods included from Base

#client, #create, #create_or_update, #delete, #get, included, #initialize, #method_missing, #new?, #respond_to?, #save, #update

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Kong::Base

Instance Method Details

#targetsArray<Kong::Target>

Returns:



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kong/upstream.rb', line 10

def targets
  targets   = []
  json_data = Client.instance.get("#{API_END_POINT}#{self.id}/targets")

  if json_data['data']
    json_data['data'].each do |target_data|
      target = Target.new(target_data)
      targets << target if target.active?
    end
  end

  targets
end