Class: Riiif::Routes
- Inherits:
-
Object
- Object
- Riiif::Routes
- Defined in:
- lib/riiif/routes.rb
Instance Method Summary collapse
- #add_routes(&blk) ⇒ Object
- #draw ⇒ Object
-
#initialize(router, options) ⇒ Routes
constructor
A new instance of Routes.
Constructor Details
#initialize(router, options) ⇒ Routes
Returns a new instance of Routes.
6 7 8 9 |
# File 'lib/riiif/routes.rb', line 6 def initialize(router, ) @router = router @options = end |
Instance Method Details
#add_routes(&blk) ⇒ Object
11 12 13 |
# File 'lib/riiif/routes.rb', line 11 def add_routes(&blk) @router.instance_exec(@options, &blk) end |
#draw ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/riiif/routes.rb', line 15 def draw add_routes do || resource = .fetch(:resource) route_prefix = [:at] route_prefix ||= "/#{[:as]}" if [:as] get "#{route_prefix}/:id/:region/:size/:rotation/:quality.:format" => 'riiif/images#show', constraints: { rotation: ALLOW_DOTS, size: SIZES }, defaults: { format: 'jpg', rotation: '0', region: 'full', quality: 'default', model: resource }, as: [:as] || 'image' get "#{route_prefix}/:id/info.json" => 'riiif/images#info', defaults: { format: 'json', model: resource }, as: [[:as], 'info'].compact.join('_') # This doesn't work presently # get "#{route_prefix}/:id", to: redirect("#{route_prefix}/%{id}/info.json") get "#{route_prefix}/:id" => 'riiif/images#redirect', as: [[:as], 'base'].compact.join('_') end end |