diff options
author | toshi <toshi@03aab468-d3d2-4883-8b12-f661bbf03fa8> | 2010-09-11 02:38:47 +0000 |
---|---|---|
committer | toshi <toshi@03aab468-d3d2-4883-8b12-f661bbf03fa8> | 2010-09-11 02:38:47 +0000 |
commit | ce0df2ba42115909e321574972c2f362a97028c2 (patch) | |
tree | 0740c36ebd2808df88a655322183688dbaced3aa /core/retriever.rb | |
parent | 7e1fd0309bc3fa68ee3a6bc3a63f21ed8eb3eb9b (diff) | |
download | mikutter-ce0df2ba42115909e321574972c2f362a97028c2.tar.gz |
git-svn-id: svn://toshia.dip.jp/mikutter/trunk@129 03aab468-d3d2-4883-8b12-f661bbf03fa8
Diffstat (limited to 'core/retriever.rb')
-rw-r--r-- | core/retriever.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/core/retriever.rb b/core/retriever.rb index bab62663..93b5e07c 100644 --- a/core/retriever.rb +++ b/core/retriever.rb @@ -43,12 +43,14 @@ module Retriever # まだそのレコードのインスタンスがない場合、それを生成して返します。 def self.new_ifnecessary(hash) - if not(hash.is_a?(Hash)) or not(hash[:id]) or hash[:id] == 0 - raise ArgumentError.new("incorrect type #{hash.inspect}") end - result = @@storage[hash[:id]] - return result if result - self.new(hash) - end + if hash.is_a?(Model) + hash + elsif not(hash.is_a?(Hash)) or not(hash[:id]) or hash[:id] == 0 + raise ArgumentError.new("incorrect type #{hash.inspect}") + else + result = @@storage[hash[:id]] + return result if result + self.new(hash) end end # # インスタンスメソッド @@ -196,7 +198,10 @@ module Retriever result = detection throw :found end } } self.retrievers_reorder - self.new_ifnecessary(result) if result.is_a? Hash end + if result.is_a? Retriever::Model + result + elsif result.is_a? Hash + self.new_ifnecessary(result) end end def self.findbyid_ary(ids, count=-1) result = [] |