Class: Nanoc::Core::ActionSequenceBuilder

Inherits:
Object
  • Object
show all
Includes:
ContractsSupport
Defined in:
lib/nanoc/core/action_sequence_builder.rb

Defined Under Namespace

Classes: CannotCreateMultipleSnapshotsWithSameNameError

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

#initialize(item_rep) ⇒ ActionSequenceBuilder

Returns a new instance of ActionSequenceBuilder.



24
25
26
27
# File 'lib/nanoc/core/action_sequence_builder.rb', line 24

def initialize(item_rep)
  @item_rep = item_rep
  @actions = []
end

Class Method Details

.build(rep) {|builder| ... } ⇒ Object

Yields:

  • (builder)


18
19
20
21
22
# File 'lib/nanoc/core/action_sequence_builder.rb', line 18

def self.build(rep)
  builder = new(rep)
  yield(builder)
  builder.action_sequence
end

Instance Method Details

#action_sequenceObject



49
50
51
# File 'lib/nanoc/core/action_sequence_builder.rb', line 49

def action_sequence
  Nanoc::Core::ActionSequence.new(@item_rep, actions: @actions)
end

#add_filter(filter_name, params) ⇒ Object



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

def add_filter(filter_name, params)
  @actions << Nanoc::Core::ProcessingActions::Filter.new(filter_name, params)
  self
end

#add_layout(layout_identifier, params) ⇒ Object



36
37
38
39
# File 'lib/nanoc/core/action_sequence_builder.rb', line 36

def add_layout(layout_identifier, params)
  @actions << Nanoc::Core::ProcessingActions::Layout.new(layout_identifier, params)
  self
end

#add_snapshot(snapshot_name, path) ⇒ Object



42
43
44
45
46
# File 'lib/nanoc/core/action_sequence_builder.rb', line 42

def add_snapshot(snapshot_name, path)
  will_add_snapshot(snapshot_name)
  @actions << Nanoc::Core::ProcessingActions::Snapshot.new([snapshot_name], path ? [path] : [])
  self
end