Skip to content

Instantly share code, notes, and snippets.

@gouravtiwari
Created August 31, 2013 05:01
Show Gist options
  • Select an option

  • Save gouravtiwari/6396316 to your computer and use it in GitHub Desktop.

Select an option

Save gouravtiwari/6396316 to your computer and use it in GitHub Desktop.
include-extend-idiom
module Goodness
def great?
@language == 'Ruby'
end
def self.included(base)
base.extend ClassMethods
def interesting
'there are thousands of spoken languages around the world'
end
end
module ClassMethods
def cool_languages
%w{Ruby Perl Python Java JavaScript Erlang}
end
end
end
class TestLanguage
include Goodness
def initialize(language)
@language = language
end
end
p TestLanguage.new('Ruby').interesting
p TestLanguage.cool_languages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment