Module: Neon::ArgumentHelpers

Included in:
Node
Defined in:
lib/helpers/argument_helpers.rb

Overview

Helpers for processing method arguments.

Instance Method Summary collapse

Instance Method Details

#extract_session(args) ⇒ Session

Extracts a session from the array of arguments if one exists at the end.

Parameters:

  • args (Array)

    an array of arguments of any type.

Returns:

  • (Session)

    a session if the last argument is a valid session and pops it out of args. Otherwise it returns the current session.



11
12
13
14
15
16
17
# File 'lib/helpers/argument_helpers.rb', line 11

def extract_session(args)
  if args.last.is_a?(Session::Rest) || args.last.is_a?(Session::Embedded)
    args.pop
  else
    Session.current
  end
end