Module: Woods::Console::Tools::Tier2
- Defined in:
- lib/woods/console/tools/tier2.rb
Overview
Tier 2: Domain-aware tools for querying live Rails data.
These tools build on Tier 1 primitives to provide higher-level domain operations: model diagnostics, data snapshots, validation, settings management, policy checks, and decorator invocation.
Each method builds a bridge request hash from validated parameters. The bridge executes the operation against the Rails environment.
Class Method Summary collapse
-
.console_check_eligibility(model:, id:, feature:) ⇒ Hash
Check feature eligibility for a record.
-
.console_check_policy(model:, id:, user_id:, action:) ⇒ Hash
Check authorization policy for a record and user.
-
.console_check_setting(key:, namespace: nil) ⇒ Hash
Check a configuration setting value.
-
.console_data_snapshot(model:, id:, associations: nil, depth: 1) ⇒ Hash
Snapshot a record with its associations for debugging.
-
.console_decorate(model:, id:, methods: nil) ⇒ Hash
Invoke a decorator on a record and return computed attributes.
-
.console_diagnose_model(model:, scope: nil, sample_size: 5) ⇒ Hash
Diagnose a model by composing multiple queries: count, recent records, and aggregates.
-
.console_update_setting(key:, value:, namespace: nil) ⇒ Hash
Update a configuration setting (requires human confirmation).
-
.console_validate_record(model:, id:, attributes: nil) ⇒ Hash
Run validations on an existing record, optionally with changed attributes.
-
.console_validate_with(model:, attributes:, context: nil) ⇒ Hash
Validate attributes against a model without persisting.
Class Method Details
.console_check_eligibility(model:, id:, feature:) ⇒ Hash
Check feature eligibility for a record.
101 102 103 |
# File 'lib/woods/console/tools/tier2.rb', line 101 def console_check_eligibility(model:, id:, feature:) { tool: 'check_eligibility', params: { model: model, id: id, feature: feature } } end |
.console_check_policy(model:, id:, user_id:, action:) ⇒ Hash
Check authorization policy for a record and user.
80 81 82 83 |
# File 'lib/woods/console/tools/tier2.rb', line 80 def console_check_policy(model:, id:, user_id:, action:) { tool: 'check_policy', params: { model: model, id: id, user_id: user_id, action: action } } end |
.console_check_setting(key:, namespace: nil) ⇒ Hash
Check a configuration setting value.
57 58 59 |
# File 'lib/woods/console/tools/tier2.rb', line 57 def console_check_setting(key:, namespace: nil) { tool: 'check_setting', params: { key: key, namespace: namespace }.compact } end |
.console_data_snapshot(model:, id:, associations: nil, depth: 1) ⇒ Hash
Snapshot a record with its associations for debugging.
36 37 38 39 40 |
# File 'lib/woods/console/tools/tier2.rb', line 36 def console_data_snapshot(model:, id:, associations: nil, depth: 1) depth = [depth, 3].min { tool: 'data_snapshot', params: { model: model, id: id, associations: associations, depth: depth }.compact } end |
.console_decorate(model:, id:, methods: nil) ⇒ Hash
Invoke a decorator on a record and return computed attributes.
111 112 113 |
# File 'lib/woods/console/tools/tier2.rb', line 111 def console_decorate(model:, id:, methods: nil) { tool: 'decorate', params: { model: model, id: id, methods: methods }.compact } end |
.console_diagnose_model(model:, scope: nil, sample_size: 5) ⇒ Hash
Diagnose a model by composing multiple queries: count, recent records, and aggregates.
24 25 26 27 |
# File 'lib/woods/console/tools/tier2.rb', line 24 def console_diagnose_model(model:, scope: nil, sample_size: 5) sample_size = [sample_size, 25].min { tool: 'diagnose_model', params: { model: model, scope: scope, sample_size: sample_size }.compact } end |
.console_update_setting(key:, value:, namespace: nil) ⇒ Hash
Update a configuration setting (requires human confirmation).
67 68 69 70 71 |
# File 'lib/woods/console/tools/tier2.rb', line 67 def console_update_setting(key:, value:, namespace: nil) { tool: 'update_setting', params: { key: key, value: value, namespace: namespace }.compact, requires_confirmation: true } end |
.console_validate_record(model:, id:, attributes: nil) ⇒ Hash
Run validations on an existing record, optionally with changed attributes.
48 49 50 |
# File 'lib/woods/console/tools/tier2.rb', line 48 def console_validate_record(model:, id:, attributes: nil) { tool: 'validate_record', params: { model: model, id: id, attributes: attributes }.compact } end |
.console_validate_with(model:, attributes:, context: nil) ⇒ Hash
Validate attributes against a model without persisting.
91 92 93 |
# File 'lib/woods/console/tools/tier2.rb', line 91 def console_validate_with(model:, attributes:, context: nil) { tool: 'validate_with', params: { model: model, attributes: attributes, context: context }.compact } end |