Class: Hecks::Bluebook::DSL::ConstShim::ScopedConstant
- Inherits:
-
Module
- Object
- Module
- Hecks::Bluebook::DSL::ConstShim::ScopedConstant
- Defined in:
- lib/hecks/bluebook/dsl/const_shim.rb
Overview
THE SCOPED-CONSTANT BRIDGE (ADR 0025, docs/dsl-work-slices.md's
S0b) — a Symbol cannot answer ::, so Account::Debit and
admits: Account::LedgerDirection could never resolve past
their FIRST segment while Account returned a bare Symbol
(resolver = ->(const) { const }, bluebook_builder.rb's own
comment on why that was right for a BARE name): Ruby's ::
operator raises TypeError on the returned value before any
DSL code runs at all, unless that value is itself a Module.
A REAL Module subclass, not a decorated Symbol, for exactly
that reason — nothing else answers ::. Every existing
consumer keeps working duck-typed, not because nothing
changed: Attribute#spell's type.is_a?(Module) branch now
fires where it used to fall to type.to_s, and
Naming.demodulise (path.split("::").last) gives the
IDENTICAL string either way for a single segment — the two
branches were already equivalent for a name with no :: in
it, which is every bareword before this.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#const_missing(name) ⇒ Object
ONE MORE SEGMENT, the same way an unresolved const anywhere else does —
Account::Debit::Anythingkeeps chaining rather than refusing, since nothing here knows how deep a reference is meant to go; the DSL keyword that finally reads.to_sis the one place that does. - #hash ⇒ Object
- #hecks_path ⇒ Object
-
#initialize(path) ⇒ ScopedConstant
constructor
A new instance of ScopedConstant.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(path) ⇒ ScopedConstant
Returns a new instance of ScopedConstant.
40 41 42 43 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 40 def initialize(path) super() @path = path end |
Class Method Details
.for(path) ⇒ Object
38 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 38 def self.for(path) = new(path.to_s) |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
57 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 57 def ==(other) = other.is_a?(ScopedConstant) ? @path == other.hecks_path : @path.to_sym == other |
#const_missing(name) ⇒ Object
ONE MORE SEGMENT, the same way an unresolved const anywhere
else does — Account::Debit::Anything keeps chaining rather
than refusing, since nothing here knows how deep a reference
is meant to go; the DSL keyword that finally reads .to_s
is the one place that does.
50 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 50 def const_missing(name) = ScopedConstant.for("#{@path}::#{name}") |
#hash ⇒ Object
59 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 59 def hash = @path.hash |
#hecks_path ⇒ Object
55 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 55 def hecks_path = @path |
#inspect ⇒ Object
54 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 54 def inspect = @path |
#to_s ⇒ Object
52 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 52 def to_s = @path |
#to_sym ⇒ Object
53 |
# File 'lib/hecks/bluebook/dsl/const_shim.rb', line 53 def to_sym = @path.to_sym |