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