Module: Conformist::Schema::Methods

Defined in:
lib/conformist/schema.rb

Instance Method Summary collapse

Instance Method Details

#builderObject



33
34
35
# File 'lib/conformist/schema.rb', line 33

def builder
  @builder ||= Builder
end

#builder=(value) ⇒ Object



37
38
39
# File 'lib/conformist/schema.rb', line 37

def builder= value
  @builder = value
end

#column(*args, &block) ⇒ Object



41
42
43
44
# File 'lib/conformist/schema.rb', line 41

def column *args, &block
  args << columns.length if args.length == 1
  columns << Column.new(*args, &block)
end

#columnsObject



46
47
48
# File 'lib/conformist/schema.rb', line 46

def columns
  @columns ||= []
end

#columns=(value) ⇒ Object



50
51
52
# File 'lib/conformist/schema.rb', line 50

def columns= value
  @columns = value
end

#conform(enumerables, options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/conformist/schema.rb', line 54

def conform enumerables, options = {}
  options = options.dup
  context = options.delete(:context)

  Enumerator.new do |yielder|
    enumerables.each do |enumerable|
      if options.delete :skip_first
        columns.each {|column| column.calculate_indices!(enumerable) }
        next
      end

      yielder.yield builder.call(self, enumerable, context)
    end
  end
end