Sha256: 4e3cc9aec9fc8f4a17778fa6463c3c1dec7705038cbac6520e37038b32ac8d55

Contents?: true

Size: 649 Bytes

Versions: 3

Compression:

Stored size: 649 Bytes

Contents

# encoding: utf-8

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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dynamic_image-2.0.3 lib/dynamic_image/routing.rb
dynamic_image-2.0.2 lib/dynamic_image/routing.rb
dynamic_image-2.0.1 lib/dynamic_image/routing.rb