Module: Dragonfly::Utils

Defined in:
lib/dragonfly/utils.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) new_tempfile(ext = nil, content = nil)



9
10
11
12
13
14
15
# File 'lib/dragonfly/utils.rb', line 9

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

+ (Object) symbolize_keys(hash)



17
18
19
20
21
22
# File 'lib/dragonfly/utils.rb', line 17

def symbolize_keys(hash)
  hash.inject({}) do |new_hash, (key, value)|
    new_hash[key.to_sym] = value
    new_hash
  end
end

+ (Object) uri_escape_segment(string)



24
25
26
# File 'lib/dragonfly/utils.rb', line 24

def uri_escape_segment(string)
  Rack::Utils.escape_path(string)
end

+ (Object) uri_unescape(string)



28
29
30
# File 'lib/dragonfly/utils.rb', line 28

def uri_unescape(string)
  URI.unescape(string)
end