Sha256: 5b287519d0779e5f38cc2407439c084cec4c85c8253ae930bd4fadc53d2b7a14

Contents?: true

Size: 941 Bytes

Versions: 6

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

module Deposit
  class EngineController < ApplicationController
    layout :get_layout

    # Used to format flash error messages
    def as_string(e)
      if e.is_a?(KillBillClient::API::ResponseError)
        "Error #{e.response.code}: #{as_string_from_response(e.response.body)}"
      else
        log_rescue_error(e)
        e.message
      end
    end

    def log_rescue_error(error)
      Rails.logger.warn "#{error.class} #{error.to_s}. #{error.backtrace.join("\n")}"
    end

    def get_layout
      layout ||= Deposit.config[:layout]
    end

    def current_tenant_user
      # If the rails application on which that engine is mounted defines such method (Devise), we extract the current user,
      # if not we default to nil, and serve our static mock configuration
      user = current_user if respond_to?(:current_user)
      Deposit.current_tenant_user.call(session, user)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
killbill-deposit-1.0.3 app/controllers/deposit/engine_controller.rb
killbill-deposit-1.0.2 app/controllers/deposit/engine_controller.rb
killbill-deposit-0.1.1 app/controllers/deposit/engine_controller.rb
killbill-deposit-1.0.1 app/controllers/deposit/engine_controller.rb
killbill-deposit-0.0.4 app/controllers/deposit/engine_controller.rb
killbill-deposit-0.0.3 app/controllers/deposit/engine_controller.rb