Module: DataMapper::YS::Proxy::ClassMethods

Defined in:
lib/dm-ys/proxy.rb

Instance Method Summary collapse

Instance Method Details

#allObject



49
50
51
# File 'lib/dm-ys/proxy.rb', line 49

def all
  records
end

#countObject



45
46
47
# File 'lib/dm-ys/proxy.rb', line 45

def count
  records.size
end

#firstObject



53
54
55
# File 'lib/dm-ys/proxy.rb', line 53

def first
  all.first
end

#get(*ids) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/dm-ys/proxy.rb', line 61

def get(*ids)
  if ids.size == 1 and !ids.first.is_a?(Array)
    all[ids.to_i]
  else
    ids.map{|id| get(id)}
  end
end

#labelsObject



37
38
39
# File 'lib/dm-ys/proxy.rb', line 37

def labels
  proxy.labels
end

#lastObject



57
58
59
# File 'lib/dm-ys/proxy.rb', line 57

def last
  all.last
end

#namesObject



33
34
35
# File 'lib/dm-ys/proxy.rb', line 33

def names
  proxy.names
end

#proxyObject



29
30
31
# File 'lib/dm-ys/proxy.rb', line 29

def proxy
  @proxy ||= Scraper.load(self)
end

#recordsObject



41
42
43
# File 'lib/dm-ys/proxy.rb', line 41

def records
  @records ||= (proxy.records.each_with_index{|r,i| r.id = i+1}; proxy.records)
end