Sha256: 6db002a21d30ffbeeae916e86054218586aba312d2ee05794e567da950d9df2b

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 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(:action_dispatch) do
  require 'jpmobile/hook_action_dispatch'
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

8 entries across 5 versions & 1 rubygems

Version Path
jpmobile-1.0.0.pre.6 lib/jpmobile/rails.rb
jpmobile-1.0.0.pre.5 lib/jpmobile/rails.rb
jpmobile-1.0.0.pre.4 test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb
jpmobile-1.0.0.pre.4 lib/jpmobile/rails.rb
jpmobile-1.0.0.pre.3 lib/jpmobile/rails.rb
jpmobile-1.0.0.pre.3 test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb
jpmobile-1.0.0.pre.2 lib/jpmobile/rails.rb
jpmobile-1.0.0.pre.2 test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb