Class: Webmachine::Response::HeaderHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/webmachine/response.rb

Overview

A Hash that can flatten array values into single values with a separator

Instance Method Summary collapse

Instance Method Details

#flattened(separator = ',') ⇒ HeaderHash

Return a new array with any Array values combined with the separator

Parameters:

  • The (String)

    separator used to join Array values

Returns:


67
68
69
70
71
72
73
74
75
76
77
# File 'lib/webmachine/response.rb', line 67

def flattened(separator = ',')
  Hash[self.collect { |k,v|
    case v
    when Array
      [k,v.join(separator)]
    else
      [k,v]
    end
  }]

end