class Thumbtack::Types::Boolean
Handles conversion and validation of Booleans to the 'yes' and 'no' parameters supported by Pinboard
@api private
Public Class Methods
deserialize(parameter)
click to toggle source
Convert a parameter from Pinboard to a boolean value
@param [String] parameter
Either 'yes' or 'no'
@return [Boolean]
# File lib/thumbtack/types/boolean.rb, line 50 def self.deserialize(parameter) case parameter when 'yes' true when 'no' false end end
serialize(value)
click to toggle source
Convert a boolean value to a parameter acceptable to Pinboard
@param [Boolean] value
the value to convert
@return [String]
'yes' if value is true, 'no' otherwise
# File lib/thumbtack/types/boolean.rb, line 35 def self.serialize(value) case value when TrueClass 'yes' when FalseClass 'no' end end
validate(value)
click to toggle source
Validate a value is a boolean parameter
@param [Boolean] value
the value to validate
@return [self]
@raise [Types::ValidationError]
if the value is not true or false
# File lib/thumbtack/types/boolean.rb, line 19 def self.validate(value) case value when TrueClass, FalseClass self else raise ValidationError, "#{value} must be true or false" end end