Class: Katalyst::Tables::Collection::Reducers::Stack

Inherits:
Object
  • Object
show all
Defined in:
app/models/concerns/katalyst/tables/collection/reducers.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeStack

Returns a new instance of Stack.



27
28
29
# File 'app/models/concerns/katalyst/tables/collection/reducers.rb', line 27

def initialize
  @stack = []
end

Instance Method Details

#build(&block) ⇒ Object



47
48
49
50
51
# File 'app/models/concerns/katalyst/tables/collection/reducers.rb', line 47

def build(&block)
  @stack.freeze.reduce(block) do |app, reducer|
    reducer.build(app)
  end
end

#index(klass) ⇒ Object



43
44
45
# File 'app/models/concerns/katalyst/tables/collection/reducers.rb', line 43

def index(klass)
  @stack.index(Reducer.new(klass))
end

#initialize_dup(other) ⇒ Object



31
32
33
# File 'app/models/concerns/katalyst/tables/collection/reducers.rb', line 31

def initialize_dup(other)
  @stack = other.instance_variable_get(:@stack).dup
end

#insert(other, klass) ⇒ Object



39
40
41
# File 'app/models/concerns/katalyst/tables/collection/reducers.rb', line 39

def insert(other, klass)
  @stack.insert(index(other), Reducer.new(klass))
end

#use(klass) ⇒ Object



35
36
37
# File 'app/models/concerns/katalyst/tables/collection/reducers.rb', line 35

def use(klass)
  @stack << Reducer.new(klass) unless index(klass)
end