module Shamu::ToBoolExtension::Strings

Add `to_model_id` to String types.

Public Instance Methods

to_bool( default = false ) click to toggle source
# File lib/shamu/to_bool_extension.rb, line 18
def to_bool( default = false )
  case self
  when "1", /\At(rue)?\z/i, /\Ay(es)?\z/i     then true
  when "0", "", /\Af(alse)?\z/i, /\An(o)?\z/i then false
  else                                             default
  end
end