Over a million developers have joined DZone.

Extract Options From Args

If we need a method with  an arbitrary number of parameters (:arg1, :arg2…) followed by a list of keyword/value options we can use the ActiveSupport method #extract_options! to find the optinons. 

def my_method(*args)
  options = args.extract_options!
  puts "Arguments:  #{args.inspect}"
  puts "Options:    #{options.inspect}"

See: http://www.simonecarletti.com/blog/2009/09/inside-ruby-on-rails-extract_options-from-arrays/

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}