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
- 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
17 18 19 20 |
# File 'lib/graphql/backtrace/table.rb', line 17 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
28 29 30 31 32 33 34 35 |
# File 'lib/graphql/backtrace/table.rb', line 28 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
23 24 25 |
# File 'lib/graphql/backtrace/table.rb', line 23 def to_table @to_table ||= render_table(rows) end |