Class: Azure::Core::FilteredService
- Defined in:
- lib/azure/core/filtered_service.rb
Overview
A base class for Service implementations
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filters ⇒ Object
Returns the value of attribute filters.
Attributes inherited from Service
Instance Method Summary collapse
- #call(method, uri, body = nil, headers = nil) ⇒ Object
-
#initialize(host = '') ⇒ FilteredService
constructor
Create a new instance of the FilteredService.
- #with_filter(filter = nil, &block) ⇒ Object
Methods inherited from Service
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
#filters ⇒ Object
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 |