Module: Tins::ExtractLastArgumentOptions
- Defined in:
- lib/tins/extract_last_argument_options.rb
Overview
Extracts the last argument from an array if it responds to to_hash
This module provides a method to separate arguments into regular arguments and options (a hash) by checking if the last element responds to to_hash
Instance Method Summary collapse
-
#extract_last_argument_options ⇒ Array<Object, Hash>
Extracts the last argument if it responds to to_hash and returns an array with the remaining elements and the extracted options hash.
Instance Method Details
#extract_last_argument_options ⇒ Array<Object, Hash>
Extracts the last argument if it responds to to_hash and returns an array with the remaining elements and the extracted options hash.
the extracted options hash
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tins/extract_last_argument_options.rb', line 12 def last_argument = last if last_argument.respond_to?(:to_hash) and = last_argument.to_hash.dup then return self[0..-2], else return dup, {} end end |