Method: ObjectLoader.load_blocks
- Defined in:
- lib/object_loader/object_loader.rb
.load_blocks(path) {|pending_object| ... } ⇒ PendingObject
Loads all object blocks from a specific path.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/object_loader/object_loader.rb', line 94 def ObjectLoader.load_blocks(path) path = File.(path) unless File.file?(path) raise(ObjectNotFound,"#{path.dump} doest not exist",caller) end # prevent circular loading of objects unless is_pending? # push on the new pending object queue.unshift(PendingObject.new(path)) begin load(path) rescue Exception => e # if any error is encountered, pop off the object queue.shift raise(e) end end # pop off and return the pending object pending_object = queue.shift yield pending_object if block_given? return pending_object end |