Sha256: c664e2e1e484f621bc9e77d6adbb946a96b686c4c6f12d5cfc313f6cacc32378

Contents?: true

Size: 836 Bytes

Versions: 3

Compression:

Stored size: 836 Bytes

Contents

require 'polygallery/view_helpers'
require 'polygallery/glue'

module Polygallery
  require 'rails'

  class Railtie < Rails::Railtie
    # initializer "polygallery.configure_rails_initialization" do |app|
    #   app.middleware.use Railtie::
    # end
    initializer "polygallery.insert_into_active_record" do |app|
      ActiveSupport.on_load :active_record do
        Polygallery::Railtie.insert
      end

      if app.config.respond_to?(:polygallery_defaults)
        Polygallery::Gallery.default_options.merge!(app.config.polygallery_defaults)
      end
    end
    initializer "polygallery.view_helpers" do
      ActionView::Base.send :include, ViewHelpers
    end
  end

  class Railtie
    def self.insert
      if defined?(ActiveRecord)
        ActiveRecord::Base.send(:include, Polygallery::Glue)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polygallery-0.1.2 lib/polygallery/railtie.rb
polygallery-0.1.1 lib/polygallery/railtie.rb
polygallery-0.1.0 lib/polygallery/railtie.rb