Class: Briefly::Definition Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Parameters:

  • canonical (Symbol)
  • aliases (Array<Symbol>)
  • body (Proc)
  • source_location (Array(String, Integer))


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

#aliasesArray<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.

Returns:

  • (Array<Symbol>)

    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

#bodyProc (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.

Returns:

  • (Proc)

    the implementation, bound to the facade at call time



15
16
17
# File 'lib/briefly/definition.rb', line 15

def body
  @body
end

#canonicalSymbol (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.

Returns:

  • (Symbol)

    the primary method name



9
10
11
# File 'lib/briefly/definition.rb', line 9

def canonical
  @canonical
end

#raw_nameSymbol (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.

Returns:

  • (Symbol)

    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_locationArray(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.

Returns:

  • (Array(String, Integer))


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.

Parameters:



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.

Returns:

  • (Boolean)


59
# File 'lib/briefly/definition.rb', line 59

def memoized? = @memoized

#namesArray<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.

Returns:

  • (Array<Symbol>)

    canonical name followed by every alias



62
# File 'lib/briefly/definition.rb', line 62

def names = [@canonical, *@aliases]