Class: StripeModelCallbacks::Subscription::StateCheckerService
- Inherits:
-
BaseService
- Object
- BaseService
- StripeModelCallbacks::Subscription::StateCheckerService
- Defined in:
- app/services/stripe_model_callbacks/subscription/state_checker_service.rb
Instance Attribute Summary collapse
-
#allowed ⇒ Object
readonly
Returns the value of attribute allowed.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(allowed:, state:) ⇒ StateCheckerService
constructor
A new instance of StateCheckerService.
- #perform ⇒ Object
Constructor Details
#initialize(allowed:, state:) ⇒ StateCheckerService
Returns a new instance of StateCheckerService.
4 5 6 7 |
# File 'app/services/stripe_model_callbacks/subscription/state_checker_service.rb', line 4 def initialize(allowed:, state:) @allowed = allowed @state = state.to_s end |
Instance Attribute Details
#allowed ⇒ Object (readonly)
Returns the value of attribute allowed.
2 3 4 |
# File 'app/services/stripe_model_callbacks/subscription/state_checker_service.rb', line 2 def allowed @allowed end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
2 3 4 |
# File 'app/services/stripe_model_callbacks/subscription/state_checker_service.rb', line 2 def state @state end |
Instance Method Details
#perform ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/stripe_model_callbacks/subscription/state_checker_service.rb', line 9 def perform if state.is_a?(Array) state.each do |state_i| response = Subscription::StateCheckerService.execute!(allowed: allowed, state: state_i) return response unless response.success? end elsif allowed.exclude?(state) return fail! ["Not allowed: #{state}"] end succeed! end |