Class: Commute::Stack::Sequence

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/commute/stack.rb

Overview

Represents one way of the Commute::Stack Delegates methods to the underlying layer array.

Instance Method Summary collapse

Instance Method Details

#after!(reference, insert) ⇒ Object

Insert a layer after another layer.

Parameters:

  • reference (Symbol)

    The layer to insert after.

  • insert (Layer)

    The layer to insert.



41
42
43
# File 'lib/commute/stack.rb', line 41

def after! reference, insert
  insert((index { |layer| layer.name == reference }) + 1, insert)
end

#before!(reference, inserting) ⇒ Object

Insert a layer before another layer.

Parameters:

  • reference (Symbol)

    The layer to insert before.

  • insert (Layer)

    The layer to insert.



33
34
35
# File 'lib/commute/stack.rb', line 33

def before! reference, inserting
  insert(index { |layer| layer.name == reference }, inserting)
end

#without!(*names) ⇒ Object

Remove some layers from this sequence.

Parameters:

  • names (<Symbol>)

    The names of the layers that must be removed.



25
26
27
# File 'lib/commute/stack.rb', line 25

def without! *names
  reject! { |layer| names.include? layer.name }
end