Skip to content

Commit

Permalink
Merge pull request #23 from peterkovacs/2.x
Browse files Browse the repository at this point in the history
Allow :only, :except, etc to be passed to has_mobile_fu
  • Loading branch information
brendanlim committed Feb 8, 2012
2 parents a151268 + 59f22a4 commit 7beac8b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/mobile_fu.rb
Expand Up @@ -21,19 +21,25 @@ module ClassMethods
# has_mobile_fu
# end
#
# You can also force mobile mode by passing in 'true'
# You can also pass any of the options available to before_filter (:only, :exclude)
#
# class WelcomeController < ActionController::Base
# has_mobile_fu :only => :index
# end
#
# You can also force mobile mode by passing in 'true' or :test_mode => true
#
# class ApplicationController < ActionController::Base
# has_mobile_fu(true)
# end

def has_mobile_fu(test_mode = false)
def has_mobile_fu(options = {})
include ActionController::MobileFu::InstanceMethods

if test_mode
before_filter :force_mobile_format
if options.respond_to?(:delete) && options.delete( :test_mode ) || options === true
before_filter :force_mobile_format, options
else
before_filter :set_mobile_format
before_filter :set_mobile_format, options
end

helper_method :is_mobile_device?
Expand Down Expand Up @@ -99,4 +105,4 @@ def is_device?(type)

end

ActionController::Base.send(:include, ActionController::MobileFu)
ActionController::Base.send(:include, ActionController::MobileFu)

0 comments on commit 7beac8b

Please sign in to comment.