module Aha::Helper

Internal: Provides helper methods for the rest of the Aha library.

Public Instance Methods

extract_option(option_key, args) click to toggle source

Internal: Extracts an option from the options hash if it exists in the method args.

option_key - A symbol corresponding to a key in the options hash. args - An array containing a number of args followed by an optional options hash.

Examples:

args_with_options = [:a, :b, :c, :d, {:key => :option}]
args_without_options = [:a, :b, :c, :d]

extract_option :key, args_with_options
# => :option

extract_option :key, args_without_options
# => nil

Returns the option value if it exists and nil otherwise.

# File lib/aha/helper.rb, line 23
def extract_option(option_key, args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  options[option_key]
end