Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CSV view context and helpers #804

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions lib/phlex/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ def initialize(collection)
@_headers = []
@_current_row = []
@_current_column_index = 0
@_view_context = nil
@_first = true
end

attr_reader :collection

def call(buffer = +"", view_context: nil)
def call(buffer = +"", context: nil)
unless escape_csv_injection? == true || escape_csv_injection? == false
raise <<~MESSAGE
You need to define escape_csv_injection? in #{self.class.name}, returning either `true` or `false`.
Expand All @@ -40,8 +39,6 @@ def escape_csv_injection? = true
MESSAGE
end

@_view_context = view_context

each_item do |record|
yielder(record) do |*args, **kwargs|
view_template(*args, **kwargs)
Expand Down Expand Up @@ -105,10 +102,6 @@ def escape_csv_injection?
nil
end

def helpers
@_view_context
end

def __escape__(value)
value = trim_whitespace? ? value.to_s.strip : value.to_s
first_char = value[0]
Expand Down