Created
April 11, 2011 18:35
-
-
Save cowboycoded/914016 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module LockApplicationController | |
module ClassMethods | |
def lock(opts={}) | |
before_filter { |c| c.lock_filter opts[:actions] } | |
end | |
end | |
module InstanceMethods | |
def lock_filter(actions=nil) | |
if locked_action?(actions) and session[:lock_opened]!=true | |
redirect_to unlock_refused_url | |
end | |
#otherwise proceed to where ya going | |
end | |
def locked_action?(actions) | |
return false if controller_name=="lock" | |
actions.blank? or actions.include?("#{controller_name}") or actions.include?("#{controller_name}##{action_name}") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment