Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Get rid of deprecation warning for InstanceMethods in ActiveSupport::…

…Concern.
  • Loading branch information...
commit 4950068dcb3fda9ea720345e4b6342cef7b6bd18 1 parent 4065e1d
Zachary Crockett authored January 24, 2012
87  lib/mobylette/controllers/respond_to_mobile_requests.rb
@@ -55,22 +55,19 @@ def respond_to_mobile_requests(options = {})
55 55
         end
56 56
       end
57 57
 
58  
-      module InstanceMethods
  58
+      private
59 59
 
60  
-        private
61  
-
62  
-        # :doc:
63  
-        # This helper returns exclusively if the request's  user_aget is from a mobile
64  
-        # device or not.
65  
-        def is_mobile_request?
66  
-          request.user_agent.to_s.downcase =~ /#{MOBILE_USER_AGENTS}/
67  
-        end
  60
+      # :doc:
  61
+      # This helper returns exclusively if the request's  user_aget is from a mobile
  62
+      # device or not.
  63
+      def is_mobile_request?
  64
+        request.user_agent.to_s.downcase =~ /#{MOBILE_USER_AGENTS}/
  65
+      end
68 66
 
69  
-        # :doc:
70  
-        # This helper returns exclusively if the current format is mobile or not
71  
-        def is_mobile_view?
72  
-          true if (request.format.to_s == "mobile") or (params[:format] == "mobile")
73  
-        end
  67
+      # :doc:
  68
+      # This helper returns exclusively if the current format is mobile or not
  69
+      def is_mobile_view?
  70
+        true if (request.format.to_s == "mobile") or (params[:format] == "mobile")
74 71
       end
75 72
     end
76 73
 
@@ -85,46 +82,44 @@ module RespondToMobileRequestsMethods
85 82
         before_filter :handle_mobile
86 83
       end
87 84
 
88  
-      module InstanceMethods
89  
-        private
  85
+      private
90 86
 
91  
-        # Returns true if this request should be treated as a mobile request
92  
-        def respond_as_mobile?
93  
-          processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? or is_mobile_request? or (params[:format] == 'mobile'))
94  
-        end
  87
+      # Returns true if this request should be treated as a mobile request
  88
+      def respond_as_mobile?
  89
+        processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? or is_mobile_request? or (params[:format] == 'mobile'))
  90
+      end
95 91
 
96  
-        # Returns true if the visitor has de force_mobile session
97  
-        def force_mobile_by_session?
98  
-          session[:mobylette_override] == :force_mobile
99  
-        end
  92
+      # Returns true if the visitor has de force_mobile session
  93
+      def force_mobile_by_session?
  94
+        session[:mobylette_override] == :force_mobile
  95
+      end
100 96
 
101  
-        # Returns true when ?skip_mobile=true is not passed to the request
102  
-        def skip_mobile_param_not_present?
103  
-          params[:skip_mobile] != 'true'
104  
-        end
  97
+      # Returns true when ?skip_mobile=true is not passed to the request
  98
+      def skip_mobile_param_not_present?
  99
+        params[:skip_mobile] != 'true'
  100
+      end
105 101
 
106  
-        # Returns true only if treating XHR requests (when skip_xhr_requests are set to false) or
107  
-        # or when this is a non xhr request
108  
-        def processing_xhr_requests?
109  
-          not self.mobylette_options[:skip_xhr_requests] && request.xhr?
110  
-        end
  102
+      # Returns true only if treating XHR requests (when skip_xhr_requests are set to false) or
  103
+      # or when this is a non xhr request
  104
+      def processing_xhr_requests?
  105
+        not self.mobylette_options[:skip_xhr_requests] && request.xhr?
  106
+      end
111 107
 
112  
-        # :doc:
113  
-        # Changes the request.form to :mobile, when the request is from
114  
-        # a mobile device
115  
-        def handle_mobile
116  
-          return if session[:mobylette_override] == :ignore_mobile
117  
-          if respond_as_mobile?
118  
-
119  
-            original_format   = request.format.to_sym
120  
-            request.format    = :mobile
121  
-            if self.mobylette_options[:fall_back] != false
122  
-              request.formats << Mime::Type.new(self.mobylette_options[:fall_back] || original_format)
123  
-            end
  108
+      # :doc:
  109
+      # Changes the request.form to :mobile, when the request is from
  110
+      # a mobile device
  111
+      def handle_mobile
  112
+        return if session[:mobylette_override] == :ignore_mobile
  113
+        if respond_as_mobile?
  114
+
  115
+          original_format   = request.format.to_sym
  116
+          request.format    = :mobile
  117
+          if self.mobylette_options[:fall_back] != false
  118
+            request.formats << Mime::Type.new(self.mobylette_options[:fall_back] || original_format)
124 119
           end
125 120
         end
126  
-
127 121
       end
  122
+
128 123
     end
129 124
   end
130 125
 end

0 notes on commit 4950068

Please sign in to comment.
Something went wrong with that request. Please try again.