Class: Azure::Core::FilteredService

Inherits:
Service
  • Object
show all
Defined in:
lib/azure/core/filtered_service.rb

Overview

A base class for Service implementations

Direct Known Subclasses

SignedService, ServiceBus::Auth::WrapService

Instance Attribute Summary collapse

Attributes inherited from Service

#host

Instance Method Summary collapse

Methods inherited from Service

#generate_uri

Constructor Details

#initialize(host = '') ⇒ FilteredService

Create a new instance of the FilteredService

host - String. The hostname. (optional, Default empty)



25
26
27
28
# File 'lib/azure/core/filtered_service.rb', line 25

def initialize(host='')
  super(host)
  @filters = []
end

Instance Attribute Details

#filtersObject

Returns the value of attribute filters.



30
31
32
# File 'lib/azure/core/filtered_service.rb', line 30

def filters
  @filters
end

Instance Method Details

#call(method, uri, body = nil, headers = nil) ⇒ Object



32
33
34
35
36
# File 'lib/azure/core/filtered_service.rb', line 32

def call(method, uri, body=nil, headers=nil)
  super(method, uri, body, headers) do |request|
    filters.each { |filter| request.with_filter filter } if filters
  end
end

#with_filter(filter = nil, &block) ⇒ Object



38
39
40
41
# File 'lib/azure/core/filtered_service.rb', line 38

def with_filter(filter=nil, &block)
  filter = filter || block
  filters.push filter if filter
end