Sha256: 1c156a84664fd3a26d0ccfa905553e36fbf0ea8757d26559baf266d978e7fa42

Contents?: true

Size: 726 Bytes

Versions: 14

Compression:

Stored size: 726 Bytes

Contents

require 'active_support/concern'

module Journey::Resource::Attachments
  extend ActiveSupport::Concern

  included do
    def self.attachment(attr)
      define_method "#{attr}_path" do |size='original'|
        if respond_to?(:display_attachments)
          if display_attachments.respond_to?(attr) && paths = display_attachments.send(attr)
            paths.send(size)
          end
        end
      end

      define_method "#{attr}_url" do |size='original'|
        uri = URI.parse(Journey.configuration.api_site)
        if path = send("#{attr}_path", size)
          path, query = *path.split("?")
          uri.path = path
          uri.query = query
          return uri.to_s
        end
      end
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
embark-journey-0.2.1 lib/journey/resource/attachments.rb
embark-journey-0.1.8 lib/journey/resource/attachments.rb
embark-journey-0.1.7 lib/journey/resource/attachments.rb
embark-journey-0.1.6 lib/journey/resource/attachments.rb
embark-journey-0.1.5 lib/journey/resource/attachments.rb
embark-journey-0.1.4 lib/journey/resource/attachments.rb
embark-journey-0.1.3 lib/journey/resource/attachments.rb
embark-journey-0.1.1 lib/journey/resource/attachments.rb
embark-journey-0.1.0 lib/journey/resource/attachments.rb
embark-journey-0.0.29 lib/journey/resource/attachments.rb
embark-journey-0.0.28 lib/journey/resource/attachments.rb
embark-journey-0.0.27 lib/journey/resource/attachments.rb
embark-journey-0.0.26 lib/journey/resource/attachments.rb
embark-journey-0.0.25 lib/journey/resource/attachments.rb