mernen (owner)

Revisions

gist: 58063 Download_button fork
public
Public Clone URL: git://gist.github.com/58063.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def coerce_to_array(v)
  if v.IS_A?(Array) # internal test, not #is_a? method call
    v
  elsif v.respond_to?(:to_ary) # replace with to_a for 1.9
    result = v.to_ary
    if result.IS_A?(Array)
      result
    else
      raise TypeError
    end
  else
    [v]
  end
end