Sha256: e0d997cc41fa6ce8c9cd061277aae24ec38e953272a4287153ed3b8511e5f5a0

Contents?: true

Size: 571 Bytes

Versions: 10

Compression:

Stored size: 571 Bytes

Contents

class Hash

  # Turn a hash into a method arguments.
  #
  #   h = { :list => [1,2], :base => "HI" }
  #
  # Without an argument field.
  #
  #   h.argumentize #=> [ { :list => [1,2], :base => "HI" } ]
  #
  # With an argument field.
  #
  #   h.argumentize(:list)   #=> [ 1, 2, { :base => "HI" } ]
  #   h.argumentize(:base)   #=> [ "HI", { :list => [1,2] } ]
  #
  def argumentize(args_field=nil)
    config = dup
    if args_field
      args = [config.delete(args_field)].flatten.compact
    else
      args = []
    end
    args << config
    return args
  end

end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/hash/argumentize.rb
facets-3.1.0 lib/core/facets/hash/argumentize.rb
facets-3.0.0 lib/core/facets/hash/argumentize.rb
facets-2.9.3 lib/core/facets/hash/argumentize.rb
facets-2.9.2 lib/core/facets/hash/argumentize.rb
facets-2.9.2 src/core/facets/hash/argumentize.rb
facets-2.9.1 lib/core/facets/hash/argumentize.rb
facets-2.9.0 lib/core/facets/hash/argumentize.rb
facets-2.9.0.pre.2 lib/core/facets/hash/argumentize.rb
facets-2.9.0.pre.1 lib/core/facets/hash/argumentize.rb