Skip to content

Instantly share code, notes, and snippets.

@karapetyan
Created September 24, 2015 08:22
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 karapetyan/b9f91f8e58f46fe11959 to your computer and use it in GitHub Desktop.
Save karapetyan/b9f91f8e58f46fe11959 to your computer and use it in GitHub Desktop.
module Tracking
def create(customername)
customers << new(customername)
end
def customers
@customers ||= []
end
end
class Customer
extend Tracking
attr_accessor :name
def initialize(name)
@name = name
end
def to_s
"[#{@name}]"
end
end
Customer.create("Peter")
Customer.create("Angie")
Customer.create("Bill")
puts Customer.customers.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment