Class: Middlestack::Stack::Proxy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_class, app, *args, &block) ⇒ Proxy

Returns a new instance of Proxy.



6
7
8
# File 'lib/middlestack/stack.rb', line 6

def initialize(target_class, app, *args, &block)
  @target_class, @app, @args, @block = target_class, app, args, block
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



4
5
6
# File 'lib/middlestack/stack.rb', line 4

def app
  @app
end

#argsObject (readonly)

Returns the value of attribute args.



4
5
6
# File 'lib/middlestack/stack.rb', line 4

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/middlestack/stack.rb', line 4

def block
  @block
end

#target_classObject (readonly)

Returns the value of attribute target_class.



4
5
6
# File 'lib/middlestack/stack.rb', line 4

def target_class
  @target_class
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/middlestack/stack.rb', line 10

def call(env)
  with_env(env) do |target|
    target.before if target.respond_to?(:before)
    app.call(env)
    target.after if target.respond_to?(:after)
  end
end