This file contains 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 FailingMacros | |
def self.included(base) | |
base.send(:extend, ClassMethods) | |
end | |
module ClassMethods | |
def should_indeed_fail | |
it "should indeed fail" do | |
fail "Just fail" | |
end |
This file contains 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
def self.allow(roles, options = {}) | |
class_eval do | |
def check_permission | |
# Insert your application logic here | |
if current_user.nil? or !current_user.roles.exists?(:id => roles) | |
flash[:notice] = "Go away!" | |
return check_and_redirect_to("/login") | |
end | |
end | |
end |
This file contains 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 AllowMacros | |
def self.included(mod) | |
mod.extend ClassMethods | |
end | |
module ClassMethods | |
FILTER_METHOD = :check_permission |
NewerOlder