class Acfs::Resource::Attributes::Boolean
@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
Constants
- FALSE_VALUES
Public Instance Methods
cast_value(value)
click to toggle source
@api public
Cast given object to boolean.
@param [Object] value Object to cast. @return [TrueClass, FalseClass] Casted boolean.
# File lib/acfs/resource/attributes/boolean.rb, line 28 def cast_value(value) return true if value == true return false if value == false if value.blank? nil else !FALSE_VALUES.include?(value) end end