module Gateway::Feature::CategorizeError
Public Class Methods
included(klass)
click to toggle source
# File lib/gateway/feature/categorize_error.rb, line 4 def self.included(klass) klass.class_eval do class_attribute :error_catalog, :error_categories self.error_catalog = {} self.error_categories = [:bad_gateway, :timeout, :retry] extend ClassMethods end end
Protected Instance Methods
error_callbacks_for(action, error_category)
click to toggle source
# File lib/gateway/feature/categorize_error.rb, line 26 def error_callbacks_for(action, error_category) action = action.to_s cat = self.error_catalog[error_category] return [] if cat.blank? lambdas = cat[action] ? cat[action][:lambdas] : [] default_lambdas = cat['all'][:lambdas] || [] lambdas + default_lambdas end
errors_for(action, error_category)
click to toggle source
# File lib/gateway/feature/categorize_error.rb, line 16 def errors_for(action, error_category) action = action.to_s cat = self.error_catalog[error_category] return [] if cat.blank? errors = cat[action] ? cat[action][:errors] : [] default_errors = cat['all'][:errors] || [] errors + default_errors end
run_callbacks_for(action, error_category)
click to toggle source
# File lib/gateway/feature/categorize_error.rb, line 36 def run_callbacks_for(action, error_category) action = action.to_s error_callbacks_for(action, error_category).each do |cb| cb.call self end end