Sha256: 1cad59ee9bd36111d7f59da64e9988f6c9a1d1cbf666d0c73465b1674f12b161

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

# -*- coding: utf-8 -*-
ActiveSupport.on_load(:action_controller) do
  require 'jpmobile/docomo_guid'
  require 'jpmobile/filter'
  require 'jpmobile/helpers'
  require 'jpmobile/hook_action_controller'
  require 'jpmobile/hook_action_view'
  require 'jpmobile/trans_sid'
end

ActiveSupport.on_load(:before_configuration) do
  # MobileCarrierのみデフォルトで有効
  ::Rails.application.middleware.insert_before('ActionDispatch::ParamsParser', Jpmobile::Rack::MobileCarrier)
  module Rails
    class Application
      class Configuration
        def jpmobile
          @jpmobile ||= ::Jpmobile::Configuration.new
        end
      end
    end
  end
end

module Jpmobile
  module ViewSelector
    def self.included(base)
      base.class_eval do
        before_filter :register_mobile

        self._view_paths = self._view_paths.dup
        self.view_paths.unshift(Jpmobile::Resolver.new(File.join(Rails.root, "app/views")))
      end
    end

    def register_mobile
      if request.mobile
        # register mobile
        self.lookup_context.mobile = request.mobile.variants
      end
    end

    def disable_mobile_view!
      self.lookup_context.mobile = nil
    end
  end
end

Version data entries

4 entries across 2 versions & 1 rubygems

Version Path
jpmobile-1.0.0.pre.1 lib/jpmobile/rails.rb
jpmobile-1.0.0.pre.1 test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb
jpmobile-1.0.0.pre lib/jpmobile/rails.rb
jpmobile-1.0.0.pre test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb