Class: Vop::EntityLoader
- Inherits:
-
Object
- Object
- Vop::EntityLoader
- Defined in:
- lib/vop/parts/entity_loader.rb
Instance Method Summary collapse
-
#initialize(plugin) ⇒ EntityLoader
constructor
A new instance of EntityLoader.
- #prepare(name) ⇒ Object
- #read_sources(named_sources) ⇒ Object
Constructor Details
#initialize(plugin) ⇒ EntityLoader
Returns a new instance of EntityLoader.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/vop/parts/entity_loader.rb', line 8 def initialize(plugin) @plugin = plugin @op = plugin.op @loaded = [] @plugin.inject_helpers(self) #@command = @entity #extend CommandSyntax extend EntitySyntax end |
Instance Method Details
#prepare(name) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/vop/parts/entity_loader.rb', line 21 def prepare(name) @entity = EntityDefinition.new(@plugin, name) @command = @entity @loaded << @entity @entity end |
#read_sources(named_sources) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vop/parts/entity_loader.rb', line 28 def read_sources(named_sources) # reads a hash of <name> => <source string> named_sources.each do |name, source| prepare(name) begin self.instance_eval(source[:code], source[:file_name]) rescue SyntaxError => detail raise Errors::EntityLoadError.new("problem loading entity #{name} : #{detail.}") end end @loaded end |