Class: Calligraphy::Lock
- Inherits:
-
WebDavRequest
- Object
- WebDavRequest
- Calligraphy::Lock
- Includes:
- XML::Utils
- Defined in:
- lib/calligraphy/web_dav_request/lock.rb
Overview
Responsible for taking out a lock of any access type and refreshing existing locks.
Instance Attribute Summary collapse
-
#resource_exists ⇒ Object
readonly
Returns the value of attribute resource_exists.
Attributes inherited from WebDavRequest
#headers, #request, #resource, #response
Instance Method Summary collapse
-
#execute ⇒ Object
Executes the WebDAV request for a particular resource.
-
#initialize(headers:, request:, response:, resource:) ⇒ Lock
constructor
:nodoc:.
Methods included from XML::Utils
Constructor Details
#initialize(headers:, request:, response:, resource:) ⇒ Lock
:nodoc:
12 13 14 15 16 17 |
# File 'lib/calligraphy/web_dav_request/lock.rb', line 12 def initialize(headers:, request:, response:, resource:) super # Determine is resource already exists before lock operation. @resource_exists = @resource.exists? end |
Instance Attribute Details
#resource_exists ⇒ Object (readonly)
Returns the value of attribute resource_exists.
9 10 11 |
# File 'lib/calligraphy/web_dav_request/lock.rb', line 9 def resource_exists @resource_exists end |
Instance Method Details
#execute ⇒ Object
Executes the WebDAV request for a particular resource.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/calligraphy/web_dav_request/lock.rb', line 20 def execute if refresh_lock? lock_properties = @resource.refresh_lock elsif resource_locked? return :locked else # The `lockinfo` tag is used to specify the type of lock the client # wishes to have created. xml = xml_for body: body, node: 'lockinfo' return :bad_request if xml == :bad_request lock_properties = @resource.lock xml, @headers['Depth'] end build_response lock_properties end |