Method: Kernel#extract_options_from_args!

Defined in:
lib/merb-core/core_ext/kernel.rb

#extract_options_from_args!(args) ⇒ Object

Extracts an options hash if it is the last item in the args array. Used internally in methods that take *args.

:api: public

Examples:

def render(*args,&blk)
  opts = extract_options_from_args!(args) || {}
  # [...]
end

Parameters:

  • args (Array)

    The arguments to extract the hash from.



223
224
225
# File 'lib/merb-core/core_ext/kernel.rb', line 223

def extract_options_from_args!(args)
  args.pop if (args.last.instance_of?(Hash) || args.last.instance_of?(Mash))
end