Skip to content

Instantly share code, notes, and snippets.

@saturnflyer

saturnflyer/prepended.rb

Forked from cmar/prepended.rb
Last active May 11, 2017
Embed
What would you like to do?
example of prepended class methods
class Foo
def self.say
p "hello from Foo"
end
end
module Bar
def say
super
p "hello from Bar"
end
end
Foo.say # => "hello from Foo"
Foo.singleton_class.prepend Bar
Foo.say # => "hello from Foo"\"hello from Bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment