module RailsConnector class S3Blob class << self def s3_objects @s3_objects ||= s3_api.buckets[bucket_name].objects end def s3_api AWS::S3.new( :access_key_id => access_key_id, :secret_access_key => secret_access_key ) end def configure(spec) @spec = spec.symbolize_keys end def find(id, options) new(id) end private attr_reader :spec def bucket_name spec[:bucket_name] end def access_key_id spec[:access_key_id] end def secret_access_key spec[:secret_access_key] end end attr_reader :id def initialize(id) @id = id end def s3_object @s3_object = self.class.s3_objects[id] end def url s3_object.public_url.to_s end def content_type s3_object.content_type end def length s3_object.content_length end end end # module RailsConnector