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

Instance Attribute Summary collapse

Attributes inherited from Service

#client, #host

Instance Method Summary collapse

Methods inherited from Service

#generate_uri

Constructor Details

#initialize(host = '', options = {}) ⇒ FilteredService

Create a new instance of the FilteredService

Parameters:

  • host (String) (defaults to: '')

    The hostname. (optional, Default empty)

  • options (Hash) (defaults to: {})

    options including :client (optional, Default {})



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

def initialize(host='', options={})
  super
  @filters = []
end

Instance Attribute Details

#filtersObject

Returns the value of attribute filters.



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

def filters
  @filters
end

Instance Method Details

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



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

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

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



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

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