lib/symmetric_encryption/coerce.rb in symmetric-encryption-4.0.0 vs lib/symmetric_encryption/coerce.rb in symmetric-encryption-4.0.1
- old
+ new
@@ -7,11 +7,11 @@
float: Float,
decimal: BigDecimal,
datetime: DateTime,
time: Time,
date: Date
- }
+ }.freeze
# Coerce given value into given type
# Does not coerce json or yaml values
def self.coerce(value, type, from_type = nil)
return value if value.nil? || (value == '')
@@ -40,11 +40,11 @@
when :json
JSON.load(value)
when :yaml
YAML.load(value)
else
- self.coerce(value, type, String)
+ coerce(value, type, String)
end
end
# Uses coercible gem to coerce values to strings from the specified type
# Note: if the type is :string, and value is not nil, then #to_s is called
@@ -58,11 +58,11 @@
when :json
value.to_json
when :yaml
value.to_yaml
else
- self.coerce(value, :string, coercion_type(type, value))
+ coerce(value, :string, coercion_type(type, value))
end
end
# Returns the correct coercion type to use for the specified symbol and value
def self.coercion_type(symbol, value)
@@ -70,8 +70,7 @@
value.class
else
TYPE_MAP[symbol]
end
end
-
end
end