Skip to content

Commit

Permalink
Add each_item method
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Feb 9, 2024
1 parent 40b1613 commit 839f219
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/phlex/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(collection)
def call(buffer = +"", view_context: nil)
@_view_context = view_context

@_collection.each do |record|
each_item do |record|
collection_yielder(record) do |*args, **kwargs|
template(*args, **kwargs)

Expand Down Expand Up @@ -53,10 +53,18 @@ def column(header = nil, value)
@_current_column_index += 1
end

def each_item(&block)
@_collection.each(&block)
end

def collection_yielder(record)
yield(record)
end

def collection
@_collection
end

def template(...)
nil
end
Expand Down

0 comments on commit 839f219

Please sign in to comment.