Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b0017cee9b
Fetching contributors…

Cannot retrieve contributors at this time

file 30 lines (27 sloc) 0.652 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
String.class_eval do
  def to_boolean
    case self
    when 'true'
      true
    when 'false'
      false
    else
      nil
    end
  end
end

Hash.class_eval do
  def symbolize_keys
    inject({}) do |options, (key, value)|
      options[(key.to_sym rescue key) || key] = value
      options
    end
  end unless method_defined?(:symbolize_keys)

  def symbolize_keys!
    self.replace(self.symbolize_keys)
  end unless method_defined?(:symbolize_keys!)

  def assert_has_keys(*valid_keys)
    missing_keys = [valid_keys].flatten - keys
    raise(ArgumentError, "Missing Option(s): #{missing_keys.join(", ")}") unless missing_keys.empty?
  end
end
Something went wrong with that request. Please try again.