Skip to content

Instantly share code, notes, and snippets.

@benhoskings
Created October 15, 2008 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhoskings/16848 to your computer and use it in GitHub Desktop.
Save benhoskings/16848 to your computer and use it in GitHub Desktop.
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