Created
May 2, 2012 22:29
-
-
Save iain/2581027 to your computer and use it in GitHub Desktop.
Hiding methods
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 MethodObject | |
def call(*args, &block) | |
new(*args, &block).instance_eval { call } | |
end | |
def self.extended(cls) | |
class << cls | |
private :new | |
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
class PublishesPost | |
extend MethodObject | |
private | |
def initialize(post, user) | |
# ... | |
end | |
def call | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DCI huh? :)