This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
def hash_map() | |
self.inject({}) do |hash, (k, v)| | |
hash.merge(k => yield(k, v)) | |
end | |
end | |
end | |
{:a => 1, :b => 2}.hash_map {|k,v| v**2 } # => {:a => 1, :b => 4} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A secure S3 storage engine for Paperclip. | |
# Usage: | |
# | |
# require "paperclip/storage/s3secure" | |
# has_attached_file :image, :storage => :S3secure, :s3_permissions => :private, … | |
module Paperclip::Storage::S3secure | |
def self.extended base | |
base.extend(Paperclip::Storage::S3) | |
end |