Module: Aha::Helper

Extended by:
Helper
Included in:
Helper
Defined in:
lib/aha/helper.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#extract_option(option_key, args) ⇒ Object

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.



23
24
25
26
# 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