Class: Locomotive::Steam::Middlewares::StackProxy
- Inherits:
-
Object
- Object
- Locomotive::Steam::Middlewares::StackProxy
- Defined in:
- lib/locomotive/steam/middlewares/stack_proxy.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
Instance Method Summary collapse
- #delete(index) ⇒ Object
- #index_of(index) ⇒ Object
-
#initialize(&block) ⇒ StackProxy
constructor
A new instance of StackProxy.
- #inject(builder) ⇒ Object
- #insert_after(index, *args, &block) ⇒ Object
- #insert_before(index, *args, &block) ⇒ Object (also: #insert)
- #use(*args, &block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ StackProxy
Returns a new instance of StackProxy.
7 8 9 10 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 7 def initialize(&block) @list = [] instance_eval(&block) if block_given? end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
5 6 7 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 5 def list @list end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
5 6 7 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 5 def operations @operations end |
Instance Method Details
#delete(index) ⇒ Object
24 25 26 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 24 def delete(index) @list.delete_at(index_of(index)) end |
#index_of(index) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 36 def index_of(index) if index.is_a?(Integer) index else @list.index { |args| args[0][0] == index } end end |
#inject(builder) ⇒ Object
30 31 32 33 34 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 30 def inject(builder) @list.each do |args| builder.use(*(args[0]), &args[1]) end end |
#insert_after(index, *args, &block) ⇒ Object
20 21 22 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 20 def insert_after(index, *args, &block) @list.insert(index_of(index) + 1, [args, block]) end |
#insert_before(index, *args, &block) ⇒ Object Also known as: insert
16 17 18 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 16 def insert_before(index, *args, &block) @list.insert(index_of(index), [args, block]) end |
#use(*args, &block) ⇒ Object
12 13 14 |
# File 'lib/locomotive/steam/middlewares/stack_proxy.rb', line 12 def use(*args, &block) @list << [args, block] end |