Sha256: 644deba12b14d3dbd06e75e4c423d919fd5b2dc84a13aedb9c02c2b1df2f6c4f

Contents?: true

Size: 542 Bytes

Versions: 9

Compression:

Stored size: 542 Bytes

Contents

module Remarkable # :nodoc:
  module CoreExt
    module Array
      # Extracts 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
Array.send :include, Remarkable::CoreExt::Array

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
remarkable-4.0.0.alpha4 lib/remarkable/core/core_ext/array.rb
remarkable-4.0.0.alpha3 lib/remarkable/core/core_ext/array.rb
remarkable-4.0.0.alpha2 lib/remarkable/core/core_ext/array.rb
remarkable-4.0.0.alpha1 lib/remarkable/core_ext/array.rb
remarkable-3.1.13 lib/remarkable/core_ext/array.rb
remarkable-3.1.12 lib/remarkable/core_ext/array.rb
remarkable-3.1.11 lib/remarkable/core_ext/array.rb
remarkable-3.1.10 lib/remarkable/core_ext/array.rb
remarkable-3.1.9 lib/remarkable/core_ext/array.rb