Created
August 27, 2012 05:09
-
-
Save todesking/3485774 to your computer and use it in GitHub Desktop.
This file contains 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
# -*- coding: utf-8 -*- | |
# まだテーブル構造がちゃんと決まってないので、データをコード内にベタ書きしてある。 | |
# 将来的にはActiveRecord化してDBに保存したい。 | |
class NewModel | |
def self.find(id) | |
INSTANCES[id] || (raise "not found") | |
end | |
INSTANCES = { | |
1 => new(1, :hoge), | |
} | |
end | |
# このクライアントコードは、NewModelの実装が変わっても修正する必要がないとうれしい | |
class OtherModel < ActiveRecord::Base | |
belongs_to :new_model | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment