Sha256: 2ebc4a1aaa0ced71f90c1948d8f78c6bc85059e093c0e5297a240bb1ba31cb5c

Contents?: true

Size: 574 Bytes

Versions: 6

Compression:

Stored size: 574 Bytes

Contents

module InactiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module Array #:nodoc:
      module ExtractOptions
        # Extract options from a set of arguments. Removes and returns the last element in the array if it's a hash, otherwise returns a blank hash.
        #
        #   def options(*args)
        #     args.extract_options!
        #   end
        #
        #   options(1, 2)           # => {}
        #   options(1, 2, :a => :b) # => {:a=>:b}
        def extract_options!
          last.is_a?(::Hash) ? pop : {}
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
automate-it-0.9.2 lib/inactive_support/core_ext/array/extract_options.rb
automate-it-0.9.1 lib/inactive_support/core_ext/array/extract_options.rb
automate-it-0.9.0 lib/inactive_support/core_ext/array/extract_options.rb
automateit-0.71230 lib/inactive_support/core_ext/array/extract_options.rb
automateit-0.80116 lib/inactive_support/core_ext/array/extract_options.rb
automateit-0.80624 lib/inactive_support/core_ext/array/extract_options.rb