Method: Vagrant::Action::Warden#finalize_action
- Defined in:
- lib/vagrant/action/warden.rb
#finalize_action(action, env) ⇒ Object
A somewhat confusing function which simply initializes each middleware properly to call the next middleware in the sequence.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/vagrant/action/warden.rb', line 68 def finalize_action(action, env) klass, args, block = action # Default the arguments to an empty array. Otherwise in Ruby 1.8 # a `nil` args will actually pass `nil` into the class. args ||= [] if klass.is_a?(Class) # A action klass which is to be instantiated with the # app, env, and any arguments given klass.new(self, env, *args, &block) elsif klass.respond_to?(:call) # Make it a lambda which calls the item then forwards # up the chain lambda do |e| klass.call(e) self.call(e) end else raise "Invalid action: #{action.inspect}" end end |