Class: Nanoc::Int::AggregateDataSource

Inherits:
DataSource
  • Object
show all
Defined in:
lib/nanoc/base/repos/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



5
6
7
8
9
10
# File 'lib/nanoc/base/repos/aggregate_data_source.rb', line 5

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

  @data_sources = data_sources
  @config = config
end

Instance Method Details

#itemsObject



12
13
14
15
16
17
# File 'lib/nanoc/base/repos/aggregate_data_source.rb', line 12

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

#layoutsObject



19
20
21
22
23
24
# File 'lib/nanoc/base/repos/aggregate_data_source.rb', line 19

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