class Attribool::Value
An abstraction of any class that can convert itself to a boolean.
Public Class Methods
new(value, condition = nil)
click to toggle source
Construct the value with an optional Proc
condition.
@param [Object] value
@param [Proc] condition (default: nil)
# File lib/attribool/value.rb, line 13 def initialize(value, condition = nil) ValidatorService.call(:condition, condition) @value = value @condition = condition end
Public Instance Methods
to_boolean()
click to toggle source
Convert the value or the condition to a boolean based off truthiness.
@return [Boolean]
# File lib/attribool/value.rb, line 23 def to_boolean !!(@condition ? @condition.call(@value) : @value) end