lib/ensurance/hash_ensure.rb in ensurance-0.1.11 vs lib/ensurance/hash_ensure.rb in ensurance-0.1.12

- old
+ new

@@ -10,27 +10,27 @@ end module ClassMethods def ensure(thing) case thing.class.name - when "Hash","HashWithIndifferentAccess" + when 'Hash', 'HashWithIndifferentAccess' thing - when "String" + when 'String' JSON.parse(thing) - when "NilClass" + when 'NilClass' nil - when "ActionController::UnfilteredParameters", "ActionController::Parameters" + when 'ActionController::UnfilteredParameters', 'ActionController::Parameters' thing.permit!.to_h else if thing.respond_to?(:to_h) begin thing.to_h rescue TypeError - raise ArgumentError.new("Unhandled Type for Hash to ensure: #{thing.class}") + raise ArgumentError, "Unhandled Type for Hash to ensure: #{thing.class}" end else - raise ArgumentError.new("Unhandled Type for Hash to ensure: #{thing.class}") + raise ArgumentError, "Unhandled Type for Hash to ensure: #{thing.class}" end end end def ensure!(thing) @@ -40,6 +40,6 @@ end end end end -::Hash.prepend( Ensurance::HashEnsure ) \ No newline at end of file +::Hash.prepend(Ensurance::HashEnsure)