Skip to content

Instantly share code, notes, and snippets.

@iain
Created May 2, 2012 22:29
Show Gist options
  • Save iain/2581027 to your computer and use it in GitHub Desktop.
Save iain/2581027 to your computer and use it in GitHub Desktop.
Hiding methods
module MethodObject
def call(*args, &block)
new(*args, &block).instance_eval { call }
end
def self.extended(cls)
class << cls
private :new
end
end
end
class PublishesPost
extend MethodObject
private
def initialize(post, user)
# ...
end
def call
# ...
end
end
@txus
Copy link

txus commented May 3, 2012

DCI huh? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment