lib/dragonfly/utils.rb in dragonfly-0.9.15 vs lib/dragonfly/utils.rb in dragonfly-1.0
- old
+ new
@@ -1,13 +1,18 @@
require 'tempfile'
require 'uri'
+require 'rack'
module Dragonfly
module Utils
module_function
+ def blank?(obj)
+ obj.respond_to?(:empty?) ? obj.empty? : !obj
+ end
+
def new_tempfile(ext=nil, content=nil)
tempfile = ext ? Tempfile.new(['dragonfly', ".#{ext}"]) : Tempfile.new('dragonfly')
tempfile.binmode
tempfile.write(content) if content
tempfile.close
@@ -15,9 +20,16 @@
end
def symbolize_keys(hash)
hash.inject({}) do |new_hash, (key, value)|
new_hash[key.to_sym] = value
+ new_hash
+ end
+ end
+
+ def stringify_keys(hash)
+ hash.inject({}) do |new_hash, (key, value)|
+ new_hash[key.to_s] = value
new_hash
end
end
def uri_escape_segment(string)