Skip to content

Instantly share code, notes, and snippets.

@chancancode
Created September 3, 2010 05:41
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 chancancode/563463 to your computer and use it in GitHub Desktop.
Save chancancode/563463 to your computer and use it in GitHub Desktop.
# This is what I wanted to do...
class MyObject < SomeSuperClass
@@data_source_id = '123456'
@@data = nil
def initialize(name)
@name = name
end
def name
data_source[:prefix] + @name
end
def some_other_attr
{ :some => data_source[:some], :other => 'other', :attr => 'attribute' }
end
private
def data_source
self.class.get_data
end
def self.get_data
@@data ||= get_data(@@data_source_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment