Sha256: 67e39bac1eb407fa74f1a6ddec90a1b4a83d93b1bdc6cdae7bcb7c388caae459

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 KB

Contents

begin
require 'rails/railtie'
rescue LoadError
else
require 'global_id'
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/integer/time'

class GlobalID
  # = GlobalID Railtie
  # Set up the signed GlobalID verifier and include Active Record support.
  class Railtie < Rails::Railtie # :nodoc:
    config.global_id = ActiveSupport::OrderedOptions.new
    config.eager_load_namespaces << GlobalID

    initializer 'global_id' do |app|
      default_expires_in = 1.month
      default_app_name = app.railtie_name.remove('_application').dasherize

      GlobalID.app = app.config.global_id.app ||= default_app_name
      SignedGlobalID.expires_in = app.config.global_id.fetch(:expires_in, default_expires_in)

      config.after_initialize do
        GlobalID.app = app.config.global_id.app ||= default_app_name
        SignedGlobalID.expires_in = app.config.global_id.fetch(:expires_in, default_expires_in)

        app.config.global_id.verifier ||= begin
          GlobalID::Verifier.new(app.key_generator.generate_key('signed_global_ids'))
        rescue ArgumentError
          nil
        end
        SignedGlobalID.verifier = app.config.global_id.verifier
      end

      ActiveSupport.on_load(:active_record) do
        require 'global_id/identification'
        send :include, GlobalID::Identification
      end

      ActiveSupport.on_load(:active_record_fixture_set) do
        require 'global_id/fixture_set'
        send :extend, GlobalID::FixtureSet
      end
    end

    initializer "web_console.deprecator" do |app|
      app.deprecators[:global_id] = GlobalID.deprecator if app.respond_to?(:deprecators)
    end
  end
end

end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/globalid-1.2.1/lib/global_id/railtie.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/globalid-1.2.1/lib/global_id/railtie.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/globalid-1.2.1/lib/global_id/railtie.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/globalid-1.2.1/lib/global_id/railtie.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/globalid-1.2.1/lib/global_id/railtie.rb
globalid-1.2.1 lib/global_id/railtie.rb
globalid-1.2.0 lib/global_id/railtie.rb