lib/remi/transform.rb in remi-0.3.0 vs lib/remi/transform.rb in remi-0.3.1

- old
+ new

@@ -512,10 +512,15 @@ def default_if_blank type == :string ? '' : nil end + def truthy(value) + @truthy ||= Truthy.new(allow_nils: false).to_proc + @truthy.call(value) + end + def transform(value) if value.blank? && type != :json blank_handler(value) else case type @@ -535,9 +540,13 @@ if value.blank? && value != [] && value != {} blank_handler(value) else value.is_a?(Hash) || value.is_a?(Array) ? value : JSON.parse(value) end + when :boolean + # Ugh, there is a bug with Daru 0.1.4 that converts false values to nil when joining + # For now, we'll just standardize boolean values (#to_s) + truthy(value).to_s else raise ArgumentError, "Unknown type enforcement: #{type}" end end end