Class: Copland::Implementation::SymbolSourceDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/copland/impl/symbol-source-manager.rb

Overview

A utility class for representing a single symbol source definition. It is used only during the construction of a SymbolSourceManager class, when the ordering of the sources must be ascertained.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ SymbolSourceDefinition

Create a new SymbolSourceDefinition from the given definition. The definition should match the schema for the SymbolSources configuration point, although no checking is done here.



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/copland/impl/symbol-source-manager.rb', line 61

def initialize( definition )
  @name = definition[ 'name' ]

  source = definition[ 'source' ]
  if source.is_a?( String )
    @source = Copland::get_class( source ).new
  else
    @source = source
  end

  @before = definition[ 'before' ] || []
  @after = definition[ 'after' ] || []
end

Instance Attribute Details

#afterObject

The array of sources that this source should be ordered after.



56
57
58
# File 'lib/copland/impl/symbol-source-manager.rb', line 56

def after
  @after
end

#beforeObject

The array of sources that this source should be ordered before.



53
54
55
# File 'lib/copland/impl/symbol-source-manager.rb', line 53

def before
  @before
end

#nameObject

The name of the symbol source.



46
47
48
# File 'lib/copland/impl/symbol-source-manager.rb', line 46

def name
  @name
end

#sourceObject

The symbol source itself, either a service a directly-instantiated object.



50
51
52
# File 'lib/copland/impl/symbol-source-manager.rb', line 50

def source
  @source
end

Instance Method Details

#after?(source) ⇒ Boolean

Return true if the given source should be ordered before # self.

Returns:

  • (Boolean)


82
83
84
85
# File 'lib/copland/impl/symbol-source-manager.rb', line 82

def after?( source )
  @after.include?( source.name ) ||
    source.before.include?( @name )
end

#before?(source) ⇒ Boolean

Return true if the given source should be ordered after # self.

Returns:

  • (Boolean)


76
77
78
79
# File 'lib/copland/impl/symbol-source-manager.rb', line 76

def before?( source )
  @before.include?( source.name ) ||
    source.after.include?( @name )
end