Skip to content

Instantly share code, notes, and snippets.

@meltingice
Created May 6, 2014 15:28
Show Gist options
  • Save meltingice/bbf55db4d2ec2d10866f to your computer and use it in GitHub Desktop.
Save meltingice/bbf55db4d2ec2d10866f to your computer and use it in GitHub Desktop.
Best way to set class level data and access from instance?
class MyClass < Base
option 'value'
def some_method
puts option
end
end
@kellysutton
Copy link

class Base
  cattr_accessor :option

  def option
    self.class.option || super
  end
end

Something like that, maybe?

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