Class: Hanami::Router::Formatter::CSV Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/router/formatter/csv.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

Constant Summary collapse

DEFAULT_OPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

{
  write_headers: true
}.freeze
HEADERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

%w[METHOD PATH TO AS CONSTRAINTS].freeze

Instance Method Summary collapse

Instance Method Details

#call(routes, **csv_opts) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



39
40
41
42
43
44
45
46
# File 'lib/hanami/router/formatter/csv.rb', line 39

def call(routes, **csv_opts)
  ::CSV.generate(**DEFAULT_OPTIONS, **csv_opts) do |csv|
    csv << HEADERS if csv.write_headers?
    routes.reduce(csv) do |acc, route|
      route.head? ? acc : acc << row(route)
    end
  end
end