Sha256: cddb0f0dca8d7b4ad7ed762e65bf82be6bace202211ea756c8dfc8c511361232

Contents?: true

Size: 1.23 KB

Versions: 14

Compression:

Stored size: 1.23 KB

Contents

require 'gecko/record/base'

module Gecko
  module Record
    class Image < Base
      AVAILABLE_SIZES = [:full, :thumbnail]

      belongs_to :variant
      belongs_to :uploader, class_name: "User",   readonly: true
      attribute :name,             String
      attribute :url,              String
      attribute :position,         Integer,       readonly: true
      attribute :base_path,        String,        readonly: true
      attribute :file_name,        String,        readonly: true
      attribute :versions,         Array[String], readonly: true

      # attribute :image_processing, Boolean

      # URL for image
      #
      # @param [Symbol] :size (:full) The image size, currently only :full,
      #  :medium and :thumbnail supported
      #
      # @return [String]
      #
      # @api public
      def url(size = :full)
        super() || build_url(size)
      end

    private

      def build_url(size)
        if size == :full
          file_path = file_name
        else
          file_path = "#{size}_#{file_name}"
        end
        [base_path, file_path].join("/")
      end
    end

    class ImageAdapter < BaseAdapter
    private

      def update_record(_record)
        raise NotImplementedError
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gecko-ruby-0.9.1 lib/gecko/record/image.rb
gecko-ruby-0.9.0 lib/gecko/record/image.rb
gecko-ruby-0.8.0 lib/gecko/record/image.rb
gecko-ruby-0.2.6 lib/gecko/record/image.rb
gecko-ruby-0.7.1 lib/gecko/record/image.rb
gecko-ruby-0.7.0 lib/gecko/record/image.rb
gecko-ruby-0.6.0 lib/gecko/record/image.rb
gecko-ruby-0.5.0 lib/gecko/record/image.rb
gecko-ruby-0.2.5 lib/gecko/record/image.rb
gecko-ruby-0.2.4 lib/gecko/record/image.rb
gecko-ruby-0.2.3 lib/gecko/record/image.rb
gecko-ruby-0.2.2 lib/gecko/record/image.rb
gecko-ruby-0.2.0 lib/gecko/record/image.rb
gecko-ruby-0.1.0 lib/gecko/record/image.rb