Sha256: d745bf699fa69820ba2f58c2b9cfd9ddbdd18cf6292c8dc478e4efff627a6fe1

Contents?: true

Size: 561 Bytes

Versions: 20

Compression:

Stored size: 561 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

20 entries across 20 versions & 1 rubygems

Version Path
remarkable-3.1.7 lib/remarkable/core_ext/array.rb
remarkable-3.1.8 lib/remarkable/core_ext/array.rb
remarkable-3.0.2 lib/remarkable/core_ext/array.rb
remarkable-3.0.4 lib/remarkable/core_ext/array.rb
remarkable-3.0.5 lib/remarkable/core_ext/array.rb
remarkable-3.0.6 lib/remarkable/core_ext/array.rb
remarkable-3.0.7 lib/remarkable/core_ext/array.rb
remarkable-3.0.8 lib/remarkable/core_ext/array.rb
remarkable-3.0.1 lib/remarkable/core_ext/array.rb
remarkable-3.0.10 lib/remarkable/core_ext/array.rb
remarkable-3.0.0 lib/remarkable/core_ext/array.rb
remarkable-3.0.3 lib/remarkable/core_ext/array.rb
remarkable-3.0.9 lib/remarkable/core_ext/array.rb
remarkable-3.1.5 lib/remarkable/core_ext/array.rb
remarkable-3.1.6 lib/remarkable/core_ext/array.rb
remarkable-3.1.1 lib/remarkable/core_ext/array.rb
remarkable-3.1.0 lib/remarkable/core_ext/array.rb
remarkable-3.1.2 lib/remarkable/core_ext/array.rb
remarkable-3.1.3 lib/remarkable/core_ext/array.rb
remarkable-3.1.4 lib/remarkable/core_ext/array.rb