Sha256: f629230e82fb36c3b5ff1aef5c6fd7732b5c1805800617b1ae007dda8a99b7d2

Contents?: true

Size: 929 Bytes

Versions: 5

Compression:

Stored size: 929 Bytes

Contents

require 'roo_on_rails/rack/populate_env_from_jwt'

module RooOnRails
  module Railties
    class RooIdentity < Rails::Railtie
      initializer 'roo_on_rails.roo_identity.middleware' do |app|
        if RooOnRails::Rack::PopulateEnvFromJWT.configured?
          Rails.logger.debug '[roo_on_rails.roo_identity.middleware] loading'
          _add_middleware(app, Rails.logger)
        else
          Rails.logger.warn(
            '[roo_on_rails.roo_identity.middleware] ' \
            ' not configured, roo.identity will be unavailable'
          )
        end
      end

      private

      def _add_middleware(app, log)
        app.config.middleware.use RooOnRails::Rack::PopulateEnvFromJWT, logger: log
      rescue LoadError
        log.error(
          '[roo_on_rails.roo_identity.middleware] ' \
          'the json-jwt gem is not in the bundle so Roo Identity will not be available'
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roo_on_rails-2.2.2 lib/roo_on_rails/railties/roo_identity.rb
roo_on_rails-2.2.1 lib/roo_on_rails/railties/roo_identity.rb
roo_on_rails-2.2.0 lib/roo_on_rails/railties/roo_identity.rb
roo_on_rails-2.1.2 lib/roo_on_rails/railties/roo_identity.rb
roo_on_rails-2.1.0 lib/roo_on_rails/railties/roo_identity.rb