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, options = {}) ⇒ Object
-
#initialize(host = '', options = {}) ⇒ FilteredService
constructor
Create a new instance of the FilteredService.
- #with_filter(filter = nil, &block) ⇒ Object
Methods inherited from Service
Constructor Details
#initialize(host = '', options = {}) ⇒ FilteredService
Create a new instance of the FilteredService
26 27 28 29 |
# File 'lib/azure/core/filtered_service.rb', line 26 def initialize(host='', ={}) super @filters = [] end |
Instance Attribute Details
#filters ⇒ Object
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, ={}) super(method, uri, body, headers) do |request| filters.reverse.each { |filter| request.with_filter filter, } 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 |