Module: ActionDispatch::Routing::Mapper::Resources

Defined in:
lib/calligraphy/rails/mapper.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Resource

Instance Method Summary collapse

Instance Method Details

#calligraphy_resource(*resources, &block) ⇒ Object

With Calligraphy, a resourceful route provides mappings between WebDAV HTTP verbs and URLs and WebDAV controller actions. A single entry in the routing file, such as:

calligraphy_resource :photos

creates eleven different routes in your application, all mapping to the WebDavRequests controller:

OPTIONS   /photos/*resource
GET       /photos/*resource
PUT       /photos/*resource
DELETE    /photos/*resource
COPY      /photos/*resource
MOVE      /photos/*resource
MKCOL     /photos/*resource
PROPFIND  /photos/*resource
PROPPATCH /photos/*resource
LOCK      /photos/*resource
UNLOCK    /photos/*resource


140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/calligraphy/rails/mapper.rb', line 140

def calligraphy_resource(*resources, &block)
  options = resources.extract_options!.dup

  if apply_common_behavior_for :calligraphy_resource, resources, options, &block
    return self
  end

  with_scope_level(:resource) do
    options = apply_action_options options

    resource_scope(SingletonResource.new(resources.pop, api_only?, @scope[:shallow], options)) do
      yield if block_given?

      concerns(options[:concerns]) if options[:concerns]

      set_mappings_for_web_dav_resources
    end
  end
end