Class: VisualModels::Config
- Inherits:
-
Object
- Object
- VisualModels::Config
- Defined in:
- lib/visual_models/config.rb
Overview
Configuration for the visual_models engine.
Instance Attribute Summary collapse
-
#base_class ⇒ Object
Abstract base(s) whose descendants are introspected.
-
#exclude ⇒ Object
Array of class-name strings or Regexp patterns.
-
#include_active_model ⇒ Object
Whether to also pull in ActiveModel-only classes (those that include ActiveModel::Model or ActiveModel::Attributes) — handy for form objects.
-
#password ⇒ Object
HTTP Basic Auth credentials.
-
#scopes ⇒ Object
Hash of label => filter.
-
#title ⇒ Object
Page title shown in the browser tab and header.
-
#username ⇒ Object
HTTP Basic Auth credentials.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
66 67 68 69 70 71 72 73 74 |
# File 'lib/visual_models/config.rb', line 66 def initialize @username = nil @password = nil @title = 'Model Graph' @base_class = nil # auto-discover every AR hierarchy @include_active_model = false @exclude = [] @scopes = { 'all' => nil } end |
Instance Attribute Details
#base_class ⇒ Object
Abstract base(s) whose descendants are introspected.
Accepts:
- nil — auto-discover. Walks `ActiveRecord::Base.descendants`, which
catches ApplicationRecord, AuditRecord, AnalyticsRecord, and any
other abstract base your app defines. Recommended default.
- String — single class name, e.g. 'ApplicationRecord'.
- Array — list of class names, e.g. ['ApplicationRecord', 'AuditRecord'].
47 48 49 |
# File 'lib/visual_models/config.rb', line 47 def base_class @base_class end |
#exclude ⇒ Object
Array of class-name strings or Regexp patterns. Any model whose name matches is dropped from the graph.
55 56 57 |
# File 'lib/visual_models/config.rb', line 55 def exclude @exclude end |
#include_active_model ⇒ Object
Whether to also pull in ActiveModel-only classes (those that include ActiveModel::Model or ActiveModel::Attributes) — handy for form objects.
51 52 53 |
# File 'lib/visual_models/config.rb', line 51 def include_active_model @include_active_model end |
#password ⇒ Object
HTTP Basic Auth credentials. Leave nil to disable auth entirely.
34 35 36 |
# File 'lib/visual_models/config.rb', line 34 def password @password end |
#scopes ⇒ Object
Hash of label => filter. Each entry becomes a tab.
Filter values:
- nil — all classes (after `exclude` is applied)
- Regexp — keep models whose name matches
- Proc — invoked at request time, must return an array of classes
- Array — explicit list of class names (strings) or class objects
64 65 66 |
# File 'lib/visual_models/config.rb', line 64 def scopes @scopes end |
#title ⇒ Object
Page title shown in the browser tab and header.
37 38 39 |
# File 'lib/visual_models/config.rb', line 37 def title @title end |
#username ⇒ Object
HTTP Basic Auth credentials. Leave nil to disable auth entirely.
34 35 36 |
# File 'lib/visual_models/config.rb', line 34 def username @username end |