Sha256: 9600e90e74512ba37b93421445e10604b111e85e2e50e985537e4b02e4f14ce4
Contents?: true
Size: 497 Bytes
Versions: 33
Compression:
Stored size: 497 Bytes
Contents
module ActiveMetadata::Helpers def to_bool str return true if str == true || str =~ (/(true|t|yes|y|1)$/i) return false if str == false || str.blank? || str =~ (/(false|f|no|n|0)$/i) raise ArgumentError.new("invalid value for Boolean: \"#{str}\"") end end class String # transform a symbol/string into a class def to_class self.to_s.camelize.constantize end end class Symbol # transform a symbol/string into a class def to_class self.to_s.to_class end end
Version data entries
33 entries across 33 versions & 1 rubygems