Created
September 3, 2010 05:41
-
-
Save chancancode/563463 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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