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

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

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


132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/calligraphy/rails/mapper.rb', line 132

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
    singleton_resoure = ActionDispatch::Routing::Mapper::SingletonResource

    resource_scope(singleton_resoure.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