Module: Woods::Console::Tools::Tier4
- Defined in:
- lib/woods/console/tools/tier4.rb
Overview
Tier 4: Guarded tools requiring confirmation or SQL validation.
-
‘console_eval` — Arbitrary Ruby execution with confirmation + timeout
-
‘console_sql` — Read-only SQL (validated by SqlValidator)
-
‘console_query` — Enhanced query builder with joins/grouping
Each method builds a bridge request hash. The bridge executes against the live Rails environment.
Constant Summary collapse
- MAX_EVAL_TIMEOUT =
30- MIN_EVAL_TIMEOUT =
1- DEFAULT_EVAL_TIMEOUT =
10- MAX_SQL_LIMIT =
10_000- MAX_QUERY_LIMIT =
10_000
Class Method Summary collapse
-
.console_eval(code:, timeout: DEFAULT_EVAL_TIMEOUT, guard: nil) ⇒ Hash
Arbitrary Ruby evaluation with timeout.
-
.console_query(model:, select:, joins: nil, group_by: nil, having: nil, order: nil, scope: nil, limit: nil) ⇒ Hash
Enhanced query builder with joins and grouping.
-
.console_sql(sql:, validator:, limit: nil) ⇒ Hash
Read-only SQL execution with validation.
Class Method Details
.console_eval(code:, timeout: DEFAULT_EVAL_TIMEOUT, guard: nil) ⇒ Hash
Arbitrary Ruby evaluation with timeout.
34 35 36 37 38 |
# File 'lib/woods/console/tools/tier4.rb', line 34 def console_eval(code:, timeout: DEFAULT_EVAL_TIMEOUT, guard: nil) guard&.check!(code) timeout = timeout.clamp(MIN_EVAL_TIMEOUT, MAX_EVAL_TIMEOUT) { tool: 'eval', params: { code: code, timeout: timeout } } end |
.console_query(model:, select:, joins: nil, group_by: nil, having: nil, order: nil, scope: nil, limit: nil) ⇒ Hash
Enhanced query builder with joins and grouping.
rubocop:disable Metrics/ParameterLists
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/woods/console/tools/tier4.rb', line 65 def console_query(model:, select:, joins: nil, group_by: nil, having: nil, order: nil, scope: nil, limit: nil) limit = [limit, MAX_QUERY_LIMIT].min if limit { tool: 'query', params: { model: model, select: select, joins: joins, group_by: group_by, having: having, order: order, scope: scope, limit: limit }.compact } end |
.console_sql(sql:, validator:, limit: nil) ⇒ Hash
Read-only SQL execution with validation.
47 48 49 50 51 |
# File 'lib/woods/console/tools/tier4.rb', line 47 def console_sql(sql:, validator:, limit: nil) validator.validate!(sql) limit = [limit, MAX_SQL_LIMIT].min if limit { tool: 'sql', params: { sql: sql, limit: limit }.compact } end |