Sha256: ab9629c2c2ca6f1217501b331d3f13bacc2beb85d7d1c8d529a9f9ef3d2bff07
Contents?: true
Size: 834 Bytes
Versions: 24
Compression:
Stored size: 834 Bytes
Contents
module Acfs::Model module Attributes # @api public # # Boolean attribute type. Use it in your model as an attribute type: # # @example # class User # include Acfs::Model # attribute :name, :boolean # end # # Given objects will be converted to string. The following strings # are considered true, everything else false: # # true, on, yes # module Boolean TRUE_VALUES = %w(true on yes) # @api public # # Cast given object to boolean. # # @param [Object] obj Object to cast. # @return [TrueClass, FalseClass] Casted boolean. # def self.cast(obj) return true if obj.is_a? TrueClass return false if obj.is_a? FalseClass TRUE_VALUES.include? obj.to_s end end end end
Version data entries
24 entries across 24 versions & 1 rubygems