Sha256: 1c1791b6663381dd8665bc59fa3d95a51ddd3204e1a1cacfb00b662d159b1c6a
Contents?: true
Size: 761 Bytes
Versions: 1
Compression:
Stored size: 761 Bytes
Contents
# frozen_string_literal: true module Paperweight # The location of the attachment in terms of paths are URLs. class Location attr_reader :model, :style def initialize(model, style = :original) @model = model @style = style end def path "#{table_name}/#{model.id}-#{style}-#{model.image_uuid}" end def url "#{self.class.prefix}/uploads/#{path}" end def default_url "#{self.class.prefix}/assets/#{table_name}/#{style}.gif" end def self.prefix @prefix ||= if Rails.env.production? Paperweight.config.asset_server else 'http://localhost:3000' end end private def table_name model.class.table_name end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paperweight-0.0.2 | lib/paperweight/location.rb |