lib/super_settings/coerce.rb in super_settings-0.0.0.rc1 vs lib/super_settings/coerce.rb in super_settings-0.0.1.rc1
- old
+ new
@@ -16,10 +16,11 @@
].to_set.freeze
# rubocop:enable Lint/BooleanSymbol
class << self
# Cast variations of booleans (i.e. "true", "false", 1, 0, etc.) to actual boolean objects.
+ #
# @param value [Object]
# @return [Boolean]
def boolean(value)
if value == false
false
@@ -29,10 +30,13 @@
!FALSE_VALUES.include?(value)
end
end
# Cast a value to a Time object.
+ #
+ # @param value [Object]
+ # @return [Time]
def time(value)
value = nil if value.nil? || value.to_s.empty?
return nil if value.nil?
time = if value.is_a?(Numeric)
Time.at(value)
@@ -45,20 +49,20 @@
time = time.in_time_zone(Time.zone)
end
time
end
- # @return true if the value is nil or empty.
+ # @return [Boolean] true if the value is nil or empty.
def blank?(value)
return true if value.nil?
if value.respond_to?(:empty?)
value.empty?
else
value.to_s.empty?
end
end
- # @return true if the value is not nil and not empty.
+ # @return [Boolean] true if the value is not nil and not empty.
def present?(value)
!blank?(value)
end
end
end