Class: Briefly::Definition Private
- Inherits:
-
Object
- Object
- Briefly::Definition
- Defined in:
- lib/briefly/definition.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
One shortcut declaration: its canonical name, its aliases, its body, and whether it memoizes.
Instance Attribute Summary collapse
-
#aliases ⇒ Array<Symbol>
readonly
private
Additional method names delegating to the same body and memo cell.
-
#body ⇒ Proc
readonly
private
The implementation, bound to the facade at call time.
-
#canonical ⇒ Symbol
readonly
private
The primary method name.
-
#raw_name ⇒ Symbol
readonly
private
The private singleton method the body compiles to.
-
#source_location ⇒ Array(String, Integer)
private
The
[file, line]the compiled methods report.
Instance Method Summary collapse
-
#initialize(canonical, aliases, body, source_location) ⇒ Definition
constructor
private
A new instance of Definition.
-
#initialize_copy(other) ⇒ void
private
Builder copies the facade's definitions before mutating them, so an aborted pass cannot leave the live facade half-configured.
-
#memoize! ⇒ void
private
Marks the value as computed once and cached.
- #memoized? ⇒ Boolean private
-
#names ⇒ Array<Symbol>
private
Canonical name followed by every alias.
Constructor Details
#initialize(canonical, aliases, body, source_location) ⇒ Definition
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Definition.
33 34 35 36 37 38 39 40 |
# File 'lib/briefly/definition.rb', line 33 def initialize(canonical, aliases, body, source_location) @canonical = canonical @aliases = aliases @body = body @raw_name = Candor.body_name(canonical) @memoized = false @source_location = source_location end |
Instance Attribute Details
#aliases ⇒ Array<Symbol> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns additional method names delegating to the same body and memo cell.
12 13 14 |
# File 'lib/briefly/definition.rb', line 12 def aliases @aliases end |
#body ⇒ Proc (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the implementation, bound to the facade at call time.
15 16 17 |
# File 'lib/briefly/definition.rb', line 15 def body @body end |
#canonical ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the primary method name.
9 10 11 |
# File 'lib/briefly/definition.rb', line 9 def canonical @canonical end |
#raw_name ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the private singleton method the body compiles to.
18 19 20 |
# File 'lib/briefly/definition.rb', line 18 def raw_name @raw_name end |
#source_location ⇒ Array(String, Integer)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The [file, line] the compiled methods report. Builder#shortcut resolves it — the body's
own location, or the shortcut call site for a bodiless-of-location Proc like &:upcase — and
Builder#namespace overwrites it: its child-returning proc literal lives in builder.rb,
and a namespace that pointed there would reintroduce, for namespaces, the lie this field exists to
remove.
27 28 29 |
# File 'lib/briefly/definition.rb', line 27 def source_location @source_location end |
Instance Method Details
#initialize_copy(other) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Builder copies the facade's definitions before mutating them, so an aborted pass cannot leave the live facade half-configured. Hash#dup would share this array.
47 48 49 50 |
# File 'lib/briefly/definition.rb', line 47 def initialize_copy(other) super @aliases = other.aliases.dup end |
#memoize! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Marks the value as computed once and cached. A redeclared shortcut is a fresh, unmemoized Definition, so there is no un-memoize.
56 |
# File 'lib/briefly/definition.rb', line 56 def memoize! = @memoized = true |
#memoized? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 |
# File 'lib/briefly/definition.rb', line 59 def memoized? = @memoized |
#names ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns canonical name followed by every alias.
62 |
# File 'lib/briefly/definition.rb', line 62 def names = [@canonical, *@aliases] |