Class: GraphQL::Backtrace::Table
- Inherits:
-
Object
- Object
- GraphQL::Backtrace::Table
- Defined in:
- lib/graphql/backtrace/table.rb
Overview
A class for turning a context into a human-readable table or array
Constant Summary collapse
- MIN_COL_WIDTH =
4
- MAX_COL_WIDTH =
100
- HEADERS =
[ "Loc", "Field", "Object", "Arguments", "Result", ]
Instance Method Summary collapse
-
#initialize(context, value:) ⇒ Table
constructor
A new instance of Table.
-
#to_backtrace ⇒ Array<String>
An array of position + field name entries.
-
#to_table ⇒ String
A table layout of backtrace with metadata.
Constructor Details
#initialize(context, value:) ⇒ Table
Returns a new instance of Table.
16 17 18 19 |
# File 'lib/graphql/backtrace/table.rb', line 16 def initialize(context, value:) @context = context @override_value = value end |
Instance Method Details
#to_backtrace ⇒ Array<String>
Returns An array of position + field name entries.
27 28 29 30 31 32 33 34 |
# File 'lib/graphql/backtrace/table.rb', line 27 def to_backtrace @to_backtrace ||= begin backtrace = rows.map { |r| "#{r[0]}: #{r[1]}" } # skip the header entry backtrace.shift backtrace end end |
#to_table ⇒ String
Returns A table layout of backtrace with metadata.
22 23 24 |
# File 'lib/graphql/backtrace/table.rb', line 22 def to_table @to_table ||= render_table(rows) end |