Sha256: bbb7fc27615cdcc1b85ceddfa028bf9f0e2d7eb6a4cb215315d5c1b9b18dde1e

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

require "mobile_enhancements/route_helpers"
require "mobile_enhancements/helper_delegation"
require "rails/railtie"

module MobileEnhancements
  class Railtie < Rails::Railtie

    config.to_prepare do
      # setup our route helpers
      ActionDispatch::Routing::Mapper.send(:include, MobileEnhancements::RouteHelpers)
      # setup the path helpers
      ActionController::Base.send(:include, MobileEnhancements::HelperDelegation)
      # setup the layout calculation
      ActionController::Base.layout :determine_layout
      # if we have a custom mobile format
      if format = MobileEnhancements.configuration.mobile_format
        # register it as an alias to the HTML mime-type
        Mime::Type.register_alias "text/html", format
        # setup the format calculation
        ActionController::Base.class_eval do
          before_filter do |controller|
            controller.request.format = controller.determine_format
          end
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mobile-enhancements-0.0.2 lib/mobile_enhancements/railtie.rb