Class: Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/vop/loader.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(op, plugin) ⇒ Loader

Returns a new instance of Loader.



5
6
7
8
9
10
11
# File 'lib/vop/loader.rb', line 5

def initialize(op, plugin)
  @op = op
  @plugin = plugin
  @loaded = []

  # TODO plugin.load_helper_classes(self) unless plugin == nil
end

Instance Attribute Details

#loadedObject (readonly)

Returns the value of attribute loaded.



3
4
5
# File 'lib/vop/loader.rb', line 3

def loaded
  @loaded
end

Class Method Details

.read(op, plugin, name, source, file_name = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vop/loader.rb', line 18

def self.read(op, plugin, name, source, file_name = nil)
  loader = new(op, plugin)

  loader.from_scratch(name)
  begin
    if file_name
      loader.instance_eval source, file_name
    else
      loader.instance_eval source
    end
  rescue => detail
    raise "could not read '#{name}' : #{detail.message}\n#{detail.backtrace[0..9].join("\n")}"
  end

  loader
end

Instance Method Details

#from_scratch(name) ⇒ Object



13
14
15
16
# File 'lib/vop/loader.rb', line 13

def from_scratch(name)
  fresh = { "name" => name }
  @loaded << fresh
end