Sha256: f41d1087138d35d1c8e94aab29fd7aafda0d4aae9c7dbdf03b0480d2e5f381e8

Contents?: true

Size: 336 Bytes

Versions: 2

Compression:

Stored size: 336 Bytes

Contents


class ActionTree::CaptureHash < Hash
  def merge!(hsh)
    hsh.each {|k, v| add(k,v) }
  end

  def merge(hsh)
    dup.merge!(hsh)
  end

  def add(key, value)
    case self[key]
      when nil    then self[key] = value
      when Array  then self[key] << value
      else             self[key] = [self[key], value]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
action_tree-0.1.1 lib/action_tree/capture_hash.rb
action_tree-0.1.0 lib/action_tree/capture_hash.rb