Skip to content

Instantly share code, notes, and snippets.

@kouba-c
Created August 29, 2013 13:49
Show Gist options
  • Save kouba-c/6378343 to your computer and use it in GitHub Desktop.
Save kouba-c/6378343 to your computer and use it in GitHub Desktop.
module Gorilla
attr_accessor :gorilla
#Init variable.
def self.extended(obj)
obj.gorilla = "First Gorilla"
end
end
class Giraffe; end
#Add instance variable and accessor methods to this object.
giraffe = Giraffe.new.extend(Gorilla)
giraffe.gorilla #=> "First Gorilla"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment