Skip to content

Instantly share code, notes, and snippets.

@saturnflyer
Forked from cmar/prepended.rb
Last active May 11, 2017 12:54
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 saturnflyer/fead5b9d160286b7995f4edac2e1ea45 to your computer and use it in GitHub Desktop.
Save saturnflyer/fead5b9d160286b7995f4edac2e1ea45 to your computer and use it in GitHub Desktop.
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