module Dragonfly::Utils
Public Instance Methods
blank?(obj)
click to toggle source
# File lib/dragonfly/utils.rb, line 10 def blank?(obj) obj.respond_to?(:empty?) ? obj.empty? : !obj end
new_tempfile(ext=nil, content=nil)
click to toggle source
# File lib/dragonfly/utils.rb, line 14 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 tempfile end
stringify_keys(hash)
click to toggle source
# File lib/dragonfly/utils.rb, line 29 def stringify_keys(hash) hash.inject({}) do |new_hash, (key, value)| new_hash[key.to_s] = value new_hash end end
symbolize_keys(hash)
click to toggle source
# File lib/dragonfly/utils.rb, line 22 def symbolize_keys(hash) hash.inject({}) do |new_hash, (key, value)| new_hash[key.to_sym] = value new_hash end end
uri_escape_segment(string)
click to toggle source
# File lib/dragonfly/utils.rb, line 36 def uri_escape_segment(string) Rack::Utils.escape_path(string) end
uri_unescape(string)
click to toggle source
# File lib/dragonfly/utils.rb, line 40 def uri_unescape(string) URI.unescape(string) end