Sha256: ffc79b19d8a840b49996f961558aec414a2e076efd4dc6711215374d8a1baa7b

Contents?: true

Size: 1.37 KB

Versions: 23

Compression:

Stored size: 1.37 KB

Contents

module Dataset
  class Load # :nodoc:
    attr_reader :datasets, :dataset_binding, :helper_methods
    
    def initialize(datasets, parent_binding)
      @datasets = datasets
      @dataset_binding = SessionBinding.new(parent_binding)
      @helper_methods = Module.new
    end
    
    def execute(loaded_datasets, dataset_resolver)
      (datasets - loaded_datasets).each do |dataset|
        instance = dataset.new
        instance.extend dataset_binding.record_methods
        instance.extend dataset_binding.model_finders
        used_datasets(dataset, dataset_resolver).each do |ds|
          next unless ds.helper_methods
          instance.extend ds.helper_methods
          helper_methods.module_eval do
            include ds.helper_methods
          end
        end
        instance.load
      end
    end
    
    def used_datasets(dataset, dataset_resolver, collector = [])
      dataset.used_datasets.each do |used|
        ds = dataset_resolver.resolve(used)
        used_datasets(ds, dataset_resolver, collector)
        collector << ds
      end if dataset.used_datasets
      collector << dataset
      collector.uniq
    end
  end
  
  class Reload # :nodoc:
    attr_reader :dataset_binding, :load
    delegate :datasets, :helper_methods, :to => :load
    
    def initialize(load)
      @load = load
      @dataset_binding = SessionBinding.new(@load.dataset_binding)
    end
  end
end

Version data entries

23 entries across 23 versions & 7 rubygems

Version Path
aiwilliams-dataset-1.2.0 lib/dataset/load.rb
aiwilliams-dataset-1.3.0 lib/dataset/load.rb
aiwilliams-dataset-1.3.1 lib/dataset/load.rb
karsthammer-dataset-1.2.0 lib/dataset/load.rb
codders-dataset-1.3.2.1 lib/dataset/load.rb
radiantcms-couchrest_model-0.2.4 vendor/plugins/dataset/lib/dataset/load.rb
radiantcms-couchrest_model-0.2.2 vendor/plugins/dataset/lib/dataset/load.rb
radiantcms-couchrest_model-0.2.1 vendor/plugins/dataset/lib/dataset/load.rb
radiantcms-couchrest_model-0.2 vendor/plugins/dataset/lib/dataset/load.rb
radiantcms-couchrest_model-0.1.9 vendor/plugins/dataset/lib/dataset/load.rb
radiantcms-couchrest_model-0.1.8 vendor/plugins/dataset/lib/dataset/load.rb
radiantcms-couchrest_model-0.1.7 vendor/plugins/dataset/lib/dataset/load.rb
radiantcms-couchrest_model-0.1.6 vendor/plugins/dataset/lib/dataset/load.rb
radiantcms-couchrest_model-0.1.5 vendor/plugins/dataset/lib/dataset/load.rb
radiant-0.7.2 vendor/plugins/dataset/lib/dataset/load.rb
be9-dataset-1.3.3 lib/dataset/load.rb
radiant-0.8.2 vendor/plugins/dataset/lib/dataset/load.rb
dataset-1.3.2 lib/dataset/load.rb
dataset-1.3.1 lib/dataset/load.rb
radiant-0.8.1 vendor/plugins/dataset/lib/dataset/load.rb