Method: RText::DefaultLoader#load

Defined in:
lib/rtext/default_loader.rb

#load(options = {}) ⇒ Object

Loads or reloads model fragments from files using the file patterns or file provider specified in the constructor. Options:

:before_load
  a proc which is called before a file is actually loaded, receives the fragment to load
  into and a symbol indicating the kind of loading: :load, :load_cached, :load_update_cache
  optionally, the proc may take third argument which is the overall number of files
  default: no before load proc

:after_load
  a proc which is called after a file has been loaded, receives the fragment loaded
  optionally, the proc may take second argument which is the overall number of files
  default: no after load proc

:on_progress
  a proc which is called when some progress is made 
  receives the current fragment being loaded, the actual work done as an integer and
  the overall work to be done as an integer
  default: no on progress proc


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rtext/default_loader.rb', line 79

def load(options={})
  @before_load_proc = options[:before_load]
  @after_load_proc = options[:after_load]
  files = @file_provider.call 
  @num_files = files.size
  @files_added = []
  @files_changed = []
  @files_removed = []
  @change_detector.check_files(files)
  @progress_monitor = ProgressMonitor.new(options[:on_progress], @files_added + @files_changed)
  @files_added.each {|f| file_added(f)}
  @files_changed.each {|f| file_changed(f)}
  @files_removed.each {|f| file_removed(f)}
  @resolver.resolve_model(@model)
end