Sha256: 92f879ef290e21af7fbf1ae83b50ee4429a5761d6045a0fc761eeab2df997f59

Contents?: true

Size: 682 Bytes

Versions: 7

Compression:

Stored size: 682 Bytes

Contents

# frozen_string_literal: true

module DynamicImage
  # = DynamicImage Routing
  #
  # Extends +ActionDispatch::Routing::Mapper+ and provides a shortcut for
  # defining routes for +DynamicImage::Controller+.
  module Routing
    # Declares an image resource.
    #
    #   image_resources :avatars
    def image_resources(resource_name, options = {})
      options = {
        path: "#{resource_name}/:digest(/:size)",
        constraints: { size: /\d+x\d+/ },
        only: [:show]
      }.merge(options)
      resources resource_name, options do
        get :uncropped, on: :member
        get :original, on: :member
        get :download, on: :member
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dynamic_image-2.0.23 lib/dynamic_image/routing.rb
dynamic_image-2.0.22 lib/dynamic_image/routing.rb
dynamic_image-2.0.21 lib/dynamic_image/routing.rb
dynamic_image-2.0.20 lib/dynamic_image/routing.rb
dynamic_image-2.0.19 lib/dynamic_image/routing.rb
dynamic_image-2.0.18 lib/dynamic_image/routing.rb
dynamic_image-2.0.17 lib/dynamic_image/routing.rb