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 ⇒ Object
Returns.
-
#to_table ⇒ Object
Returns.
Constructor Details
#initialize(context, value:) ⇒ Table
Returns a new instance of Table.
18 19 20 21 |
# File 'lib/graphql/backtrace/table.rb', line 18 def initialize(context, value:) @context = context @override_value = value end |
Instance Method Details
#to_backtrace ⇒ Object
Returns
Array<String>— An array of position + field name entries
:call-seq:
to_backtrace() -> Array[String]
39 40 41 42 43 44 45 46 |
# File 'lib/graphql/backtrace/table.rb', line 39 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 ⇒ Object
Returns
String— A table layout of backtrace with metadata
:call-seq:
to_table() -> String
29 30 31 |
# File 'lib/graphql/backtrace/table.rb', line 29 def to_table @to_table ||= render_table(rows) end |