Class: Array

Class | Array
In: | lib/assistance/extract_options.rb
Parent: | Object

Array extensions

### Methods

extract_options!

### Public Instance methods

extract_options!()

Removes and returns the last member of the array if it is a hash. Otherwise, an empty hash is returned This method is useful when writing methods that take an options hash as the last parameter. For example:

      def validate_each(*args, &block)
        opts = args.extract_options!
        ...
      end

[Source]

        # File lib/assistance/extract_options.rb, line 11
    11:   def extract_options!
    12:     last.is_a?(Hash) ? pop : {}
    13:   end

[Validate]