Class: Nanoc::Core::AggregateDataSource

Inherits:
DataSource
  • Object
show all
Defined in:
lib/nanoc/core/aggregate_data_source.rb

Instance Attribute Summary

Attributes inherited from DataSource

#config, #items_root, #layouts_root

Instance Method Summary collapse

Methods inherited from DataSource

#down, #new_item, #new_layout, #unuse, #up, #use

Constructor Details

#initialize(data_sources, config) ⇒ AggregateDataSource

Returns a new instance of AggregateDataSource.



6
7
8
9
10
11
# File 'lib/nanoc/core/aggregate_data_source.rb', line 6

def initialize(data_sources, config)
  super({}, '/', '/', {})

  @data_sources = data_sources
  @config = config
end

Instance Method Details

#item_changesObject



27
28
29
# File 'lib/nanoc/core/aggregate_data_source.rb', line 27

def item_changes
  SlowEnumeratorTools.merge(@data_sources.map(&:item_changes))
end

#itemsObject



13
14
15
16
17
18
# File 'lib/nanoc/core/aggregate_data_source.rb', line 13

def items
  @_items ||= begin
    objs = @data_sources.flat_map(&:items)
    Nanoc::Core::ItemCollection.new(@config, objs)
  end
end

#layout_changesObject



31
32
33
# File 'lib/nanoc/core/aggregate_data_source.rb', line 31

def layout_changes
  SlowEnumeratorTools.merge(@data_sources.map(&:layout_changes))
end

#layoutsObject



20
21
22
23
24
25
# File 'lib/nanoc/core/aggregate_data_source.rb', line 20

def layouts
  @_layouts ||= begin
    objs = @data_sources.flat_map(&:layouts)
    Nanoc::Core::LayoutCollection.new(@config, objs)
  end
end