Module: Cheveret::Table::Data

Included in:
Base
Defined in:
lib/cheveret/table/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collectionObject



44
45
46
# File 'lib/cheveret/table/data.rb', line 44

def collection
  @collection
end

Instance Method Details

#initialize(collection = [], options = {}) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/cheveret/table/data.rb', line 33

def initialize(collection=[], options={})
  if block_given?
    yield self
  else
    config(options.merge({ :collection => collection }))
  end
end

#proxyObject



51
52
53
54
55
56
57
58
# File 'lib/cheveret/table/data.rb', line 51

[ :each, :empty?, :length, :map ].each do |proxy|
  # there is a nicer way to do this using forwardable, but this works for now
  class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
    def #{proxy}(*args)
      collection.#{proxy}(*args)
    end
  RUBY_EVAL
end