Class: RedboothRuby::ClientOperations::Perform
- Inherits:
-
Object
- Object
- RedboothRuby::ClientOperations::Perform
- Includes:
- Helpers
- Defined in:
- lib/redbooth-ruby/client_operations/perform.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#oauth_token_expired_error ⇒ Object
Returns the value of attribute oauth_token_expired_error.
-
#options ⇒ Object
Returns the value of attribute options.
-
#processing_error ⇒ Object
Returns the value of attribute processing_error.
-
#resource_name ⇒ Object
Returns the value of attribute resource_name.
-
#session ⇒ Object
Returns the value of attribute session.
-
#tries ⇒ Object
Returns the value of attribute tries.
Instance Method Summary collapse
-
#initialize(resource_name, action, session, options = {}) ⇒ Perform
constructor
A new instance of Perform.
-
#perform! ⇒ Object
Performs the resource action.
-
#perform_oauth_token_expired! ⇒ Object
Perform refresh on the session access token.
-
#perform_processing! ⇒ Object
Delays the execution of the enqueued processing.
Methods included from Helpers
Constructor Details
#initialize(resource_name, action, session, options = {}) ⇒ Perform
Returns a new instance of Perform.
8 9 10 11 12 13 14 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 8 def initialize(resource_name, action, session, = {}) @resource_name = resource_name @action = action @session = session = @tries = 0 end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
5 6 7 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 5 def action @action end |
#oauth_token_expired_error ⇒ Object
Returns the value of attribute oauth_token_expired_error.
6 7 8 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 6 def oauth_token_expired_error @oauth_token_expired_error end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 5 def end |
#processing_error ⇒ Object
Returns the value of attribute processing_error.
6 7 8 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 6 def processing_error @processing_error end |
#resource_name ⇒ Object
Returns the value of attribute resource_name.
5 6 7 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 5 def resource_name @resource_name end |
#session ⇒ Object
Returns the value of attribute session.
5 6 7 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 5 def session @session end |
#tries ⇒ Object
Returns the value of attribute tries.
6 7 8 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 6 def tries @tries end |
Instance Method Details
#perform! ⇒ Object
Performs the resource action
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 19 def perform! @tries += 1 fail RedboothRuby::AuthenticationError unless session resource(resource_name).send(action, ()) rescue Processing => processing_error @processing_error = processing_error perform_processing! rescue OauthTokenExpired => oauth_token_expired_error @oauth_token_expired_error = oauth_token_expired_error perform_oauth_token_expired! end |
#perform_oauth_token_expired! ⇒ Object
Perform refresh on the session access token
46 47 48 49 50 51 52 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 46 def perform_oauth_token_expired! if tries == 1 && refresh_session_access_token! perform! else raise oauth_token_expired_error end end |
#perform_processing! ⇒ Object
Delays the execution of the enqueued processing
34 35 36 37 38 39 40 41 |
# File 'lib/redbooth-ruby/client_operations/perform.rb', line 34 def perform_processing! delay = if processing_error && processing_error.response processing_error.response.data['retry_after'].to_i else 10 end retry_in(delay) end |