Skip to content

Instantly share code, notes, and snippets.

@sdeming
Created November 19, 2012 19:31
Show Gist options
  • Save sdeming/4113126 to your computer and use it in GitHub Desktop.
Save sdeming/4113126 to your computer and use it in GitHub Desktop.
Totally Contrived Episode #1 - class << self
class Foo
class << self
attr_accessor :a, :b
end
def self.register(args = {})
args.each do |k,v|
self.send(:"#{k}=", v)
end
end
def self.moo
a * b
end
end
class FooLish < Foo
register :a => 7, :b => 6
end
class FooNiture < Foo
register :a => 1, :b => 2
end
puts FooLish.moo
puts FooNiture.moo
@jmazzi
Copy link

jmazzi commented Nov 19, 2012

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment