class Cell::Collection
Attributes
collection_join[RW]
TODO: remove in 5.0.
method[RW]
TODO: remove in 5.0.
Public Class Methods
new(ary, options, cell_class)
click to toggle source
# File lib/cell/collection.rb, line 3 def initialize(ary, options, cell_class) options.delete(:collection) set_deprecated_options(options) # TODO: remove in 5.0. @ary = ary @options = options # these options are "final" and will be identical for all collection cells. @cell_class = cell_class end
Public Instance Methods
join(separator="") { |cell, i| ... }
click to toggle source
Iterate collection and build a cell for each item. The passed block receives that cell and the index. Its return value is captured and joined.
# File lib/cell/collection.rb, line 32 def join(separator="", &block) @ary.each_with_index.collect do |model, i| cell = @cell_class.build(model, @options) block_given? ? yield(cell, i) : cell end.join(separator) end
set_deprecated_options(options)
click to toggle source
# File lib/cell/collection.rb, line 12 def set_deprecated_options(options) # TODO: remove in 5.0. self.method = options.delete(:method) if options.include?(:method) self.collection_join = options.delete(:collection_join) if options.include?(:collection_join) end
to_s()
click to toggle source
# File lib/cell/collection.rb, line 25 def to_s call end