Created
October 15, 2008 03:06
-
-
Save benhoskings/16848 to your computer and use it in GitHub Desktop.
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
class Object | |
def metaclass | |
class << self; self; end | |
end | |
end | |
module CannedScopes | |
def self.included base | |
base.send :extend, ClassMethods | |
end | |
module ClassMethods | |
def public_resource | |
self.metaclass.instance_eval { | |
%w{read write index}.each {|verb| | |
send :define_method, verb do | |
'lul' | |
end | |
} | |
} | |
end | |
end | |
end | |
class Model | |
include CannedScopes | |
public_resource | |
end | |
Model.write |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment