Class: Copland::Implementation::SymbolSourceDefinition
- Inherits:
-
Object
- Object
- Copland::Implementation::SymbolSourceDefinition
- 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
-
#after ⇒ Object
The array of sources that this source should be ordered after.
-
#before ⇒ Object
The array of sources that this source should be ordered before.
-
#name ⇒ Object
The name of the symbol source.
-
#source ⇒ Object
The symbol source itself, either a service a directly-instantiated object.
Instance Method Summary collapse
-
#after?(source) ⇒ Boolean
Return
true
if the given source should be ordered before #self
. -
#before?(source) ⇒ Boolean
Return
true
if the given source should be ordered after #self
. -
#initialize(definition) ⇒ SymbolSourceDefinition
constructor
Create a new SymbolSourceDefinition from the given definition.
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
#after ⇒ Object
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 |
#before ⇒ Object
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 |
#name ⇒ Object
The name of the symbol source.
46 47 48 |
# File 'lib/copland/impl/symbol-source-manager.rb', line 46 def name @name end |
#source ⇒ Object
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
.
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
.
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 |