Class: AwsDevUtils::ClientWrapper
- Inherits:
-
Object
- Object
- AwsDevUtils::ClientWrapper
- Includes:
- Utils
- Defined in:
- lib/aws-dev-utils/client_wrapper.rb
Instance Method Summary collapse
-
#initialize(client, options = {}) ⇒ ClientWrapper
constructor
Initialize a new ClientWrapper, internal use only.
- #method_missing(m, *args, &block) ⇒ Object
-
#with_cache(exp = 60) ⇒ Object
ClientWrapper with cache option.
-
#with_next_token(max = 100) ⇒ Object
ClientWrapper with next_token option.
-
#with_retry(max = 5) ⇒ Object
ClientWrapper with retry option.
Methods included from Utils
Constructor Details
#initialize(client, options = {}) ⇒ ClientWrapper
Initialize a new ClientWrapper, internal use only
11 12 13 14 |
# File 'lib/aws-dev-utils/client_wrapper.rb', line 11 def initialize client, ={} @client = client @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/aws-dev-utils/client_wrapper.rb', line 31 def method_missing m, *args, &block client_name = @client.class.name @client = RetryWrapper.new(@client, @options[:retry]) if retry? @client = NextTokenWrapper.new(@client, @options[:next_token]) if next_token? @client = CacheWrapper.new(@client, @options[:cache], client_name: client_name) if cache? nested_struct(@client.send(m, *args, &block)) end |
Instance Method Details
#with_cache(exp = 60) ⇒ Object
Returns ClientWrapper with cache option.
27 28 29 |
# File 'lib/aws-dev-utils/client_wrapper.rb', line 27 def with_cache exp=60 self.class.new(@client, @options.merge(cache: exp)) end |
#with_next_token(max = 100) ⇒ Object
Returns ClientWrapper with next_token option.
17 18 19 |
# File 'lib/aws-dev-utils/client_wrapper.rb', line 17 def with_next_token max=100 self.class.new(@client, @options.merge(next_token: max)) end |
#with_retry(max = 5) ⇒ Object
Returns ClientWrapper with retry option.
22 23 24 |
# File 'lib/aws-dev-utils/client_wrapper.rb', line 22 def with_retry max=5 self.class.new(@client, @options.merge(retry: max)) end |