Class: Calligraphy::Resource
- Inherits:
-
Object
- Object
- Calligraphy::Resource
- Defined in:
- lib/calligraphy/resource.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client_nonce ⇒ Object
Returns the value of attribute client_nonce.
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#full_request_path ⇒ Object
readonly
Returns the value of attribute full_request_path.
-
#mount_point ⇒ Object
readonly
Returns the value of attribute mount_point.
-
#request_body ⇒ Object
readonly
Returns the value of attribute request_body.
-
#request_path ⇒ Object
readonly
Returns the value of attribute request_path.
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #ancestor_exist? ⇒ Boolean
- #can_copy?(options) ⇒ Boolean
- #collection? ⇒ Boolean
- #copy(options) ⇒ Object
- #create_collection ⇒ Object
- #delete_collection ⇒ Object
- #etag ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(resource: nil, req: nil, mount: nil, root_dir: nil) ⇒ Resource
constructor
A new instance of Resource.
- #lock(nodes, depth = 'infinity') ⇒ Object
- #lock_is_exclusive? ⇒ Boolean
- #lock_tokens ⇒ Object
- #locked? ⇒ Boolean
- #locked_to_user?(headers = nil) ⇒ Boolean
- #propfind(nodes) ⇒ Object
- #proppatch(nodes) ⇒ Object
- #read ⇒ Object
- #readable? ⇒ Boolean
- #refresh_lock ⇒ Object
- #unlock(token) ⇒ Object
- #write(contents = @request_body.to_s) ⇒ Object
Constructor Details
#initialize(resource: nil, req: nil, mount: nil, root_dir: nil) ⇒ Resource
Returns a new instance of Resource.
6 7 8 9 10 11 |
# File 'lib/calligraphy/resource.rb', line 6 def initialize(resource: nil, req: nil, mount: nil, root_dir: nil) @full_request_path = req&.original_url @mount_point = mount || req&.path&.tap { |s| s.slice! resource } @request_body = req&.body&.read || '' @request_path = mount.nil? ? resource : resource.split(mount)[-1] end |
Instance Attribute Details
#client_nonce ⇒ Object
Returns the value of attribute client_nonce.
3 4 5 |
# File 'lib/calligraphy/resource.rb', line 3 def client_nonce @client_nonce end |
#contents ⇒ Object
Returns the value of attribute contents.
3 4 5 |
# File 'lib/calligraphy/resource.rb', line 3 def contents @contents end |
#full_request_path ⇒ Object (readonly)
Returns the value of attribute full_request_path.
4 5 6 |
# File 'lib/calligraphy/resource.rb', line 4 def full_request_path @full_request_path end |
#mount_point ⇒ Object (readonly)
Returns the value of attribute mount_point.
4 5 6 |
# File 'lib/calligraphy/resource.rb', line 4 def mount_point @mount_point end |
#request_body ⇒ Object (readonly)
Returns the value of attribute request_body.
4 5 6 |
# File 'lib/calligraphy/resource.rb', line 4 def request_body @request_body end |
#request_path ⇒ Object (readonly)
Returns the value of attribute request_path.
4 5 6 |
# File 'lib/calligraphy/resource.rb', line 4 def request_path @request_path end |
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
4 5 6 |
# File 'lib/calligraphy/resource.rb', line 4 def root_dir @root_dir end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
3 4 5 |
# File 'lib/calligraphy/resource.rb', line 3 def updated_at @updated_at end |
Instance Method Details
#ancestor_exist? ⇒ Boolean
13 14 15 |
# File 'lib/calligraphy/resource.rb', line 13 def ancestor_exist? raise NotImplemented end |
#can_copy?(options) ⇒ Boolean
17 18 19 |
# File 'lib/calligraphy/resource.rb', line 17 def can_copy?() raise NotImplemented end |
#collection? ⇒ Boolean
21 22 23 |
# File 'lib/calligraphy/resource.rb', line 21 def collection? raise NotImplemented end |
#copy(options) ⇒ Object
25 26 27 |
# File 'lib/calligraphy/resource.rb', line 25 def copy() raise NotImplemented end |
#create_collection ⇒ Object
29 30 31 |
# File 'lib/calligraphy/resource.rb', line 29 def create_collection raise NotImplemented end |
#delete_collection ⇒ Object
33 34 35 |
# File 'lib/calligraphy/resource.rb', line 33 def delete_collection raise NotImplemented end |
#etag ⇒ Object
37 38 39 |
# File 'lib/calligraphy/resource.rb', line 37 def etag raise NotImplemented end |
#exists? ⇒ Boolean
41 42 43 |
# File 'lib/calligraphy/resource.rb', line 41 def exists? raise NotImplemented end |
#lock(nodes, depth = 'infinity') ⇒ Object
45 46 47 |
# File 'lib/calligraphy/resource.rb', line 45 def lock(nodes, depth='infinity') raise NotImplemented end |
#lock_is_exclusive? ⇒ Boolean
49 50 51 |
# File 'lib/calligraphy/resource.rb', line 49 def lock_is_exclusive? raise NotImplemented end |
#lock_tokens ⇒ Object
53 54 55 |
# File 'lib/calligraphy/resource.rb', line 53 def lock_tokens raise NotImplemented end |
#locked? ⇒ Boolean
57 58 59 |
# File 'lib/calligraphy/resource.rb', line 57 def locked? raise NotImplemented end |
#locked_to_user?(headers = nil) ⇒ Boolean
61 62 63 |
# File 'lib/calligraphy/resource.rb', line 61 def locked_to_user?(headers=nil) raise NotImplemented end |
#propfind(nodes) ⇒ Object
65 66 67 |
# File 'lib/calligraphy/resource.rb', line 65 def propfind(nodes) raise NotImplemented end |
#proppatch(nodes) ⇒ Object
69 70 71 |
# File 'lib/calligraphy/resource.rb', line 69 def proppatch(nodes) raise NotImplemented end |
#read ⇒ Object
73 74 75 |
# File 'lib/calligraphy/resource.rb', line 73 def read raise NotImplemented end |
#readable? ⇒ Boolean
77 78 79 |
# File 'lib/calligraphy/resource.rb', line 77 def readable? exists? && !collection? end |
#refresh_lock ⇒ Object
81 82 83 |
# File 'lib/calligraphy/resource.rb', line 81 def refresh_lock raise NotImplemented end |
#unlock(token) ⇒ Object
85 86 87 |
# File 'lib/calligraphy/resource.rb', line 85 def unlock(token) raise NotImplemented end |
#write(contents = @request_body.to_s) ⇒ Object
89 90 91 |
# File 'lib/calligraphy/resource.rb', line 89 def write(contents=@request_body.to_s) raise NotImplemented end |