File: datasource.rb

package info (click to toggle)
mikutter 3.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,256 kB
  • ctags: 2,165
  • sloc: ruby: 19,079; sh: 205; makefile: 20
file content (33 lines) | stat: -rw-r--r-- 961 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-

=begin rdoc
データの保存/復元を実際に担当するデータソース。
データソースをモデルにModel::add_data_retrieverにて幾つでも参加させることが出来る。
=end
module Retriever::DataSource
  USE_ALL = -1                  # findbyidの引数。全てのDataSourceから探索する
  USE_LOCAL_ONLY = -2           # findbyidの引数。ローカルにあるデータのみを使う

  attr_accessor :keys

  # idをもつデータを返す。
  # もし返せない場合は、nilを返す
  def findbyid(id, policy)
    nil
  end

  # 取得できたらそのRetrieverのインスタンスをキーにして実行されるDeferredを返す
  def idof(id)
    Thread.new{ findbyid(id) } end
  alias [] idof

  # データの保存
  # データ一件保存する。保存に成功したか否かを返す。
  def store_datum(datum)
    false
  end

  def inspect
    self.class.to_s
  end
end