Skip to content

Instantly share code, notes, and snippets.

@mcfiredrill
Created May 10, 2012 17:12
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 mcfiredrill/2654516 to your computer and use it in GitHub Desktop.
Save mcfiredrill/2654516 to your computer and use it in GitHub Desktop.
class variable as attr_accessor...
[2] pry(main)> b = Boo.new(2)
=> #<Boo:0x9deaa90 @stuff=2>
[3] pry(main)> b.blah
=> "thingsmorethings"
require 'active_support/core_ext'
class Foo
class_attribute :name
attr_accessor :stuff
def initialize(bbb)
@stuff = bbb
end
end
def Foo(name)
klass = Class.new(Foo)
klass.name = name
puts klass.name
klass
end
class Boo < Foo("things")
def blah
self.name << "morethings"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment