Ruby 3.0 compatibility

This commit is contained in:
karel.picman@lbcfree.net 2021-05-24 13:19:04 +02:00
parent d95a37814a
commit facc4e25a6

View File

@ -56,8 +56,8 @@ module DAV4Rack
end end
end end
def render_lockdiscovery(options={}) def render_lockdiscovery(**options)
render_xml ox_element(D_PROP, ox_element(D_LOCKDISCOVERY, activelock(options))) render_xml ox_element(D_PROP, ox_element(D_LOCKDISCOVERY, activelock(**options)))
end end
# #
@ -81,24 +81,24 @@ module DAV4Rack
private private
def activelock(options) def activelock(time: nil, token:, depth:, scope: nil, type: nil, owner: nil, root: nil)
Ox::Element.new(D_ACTIVELOCK).tap do |activelock| Ox::Element.new(D_ACTIVELOCK).tap do |activelock|
if options[:scope] if scope
scope = Ox::Element.new("#{DAV_NAMESPACE_NAME}:#{options[:scope]}") value = Ox::Element.new("#{DAV_NAMESPACE_NAME}:#{scope}")
activelock << ox_element(D_LOCKSCOPE, scope) activelock << ox_element(D_LOCKSCOPE, value)
end end
if options[:type] if type
type = Ox::Element.new("#{DAV_NAMESPACE_NAME}:#{options[:type]}") value = Ox::Element.new("#{DAV_NAMESPACE_NAME}:#{type}")
activelock << ox_element(D_LOCKTYPE, type) activelock << ox_element(D_LOCKTYPE, value)
end end
activelock << ox_element(D_DEPTH, options[:depth]) activelock << ox_element(D_DEPTH, depth)
activelock << ox_element(D_TIMEOUT, (options[:time] ? "Second-#{options[:time]}" : INFINITY)) activelock << ox_element(D_TIMEOUT, (time ? "Second-#{time}" : INFINITY))
token = ox_element(D_HREF, options[:token]) value = ox_element(D_HREF, token)
activelock << ox_element(D_LOCKTOKEN, token) activelock << ox_element(D_LOCKTOKEN, value)
activelock << ox_element(D_OWNER, options[:owner]) if options[:owner] activelock << ox_element(D_OWNER, owner) if owner
if options[:root] if root
root = ox_element(D_HREF, options[:root]) value = ox_element(D_HREF, root)
activelock << ox_element(D_LOCKROOT, root) activelock << ox_element(D_LOCKROOT, value)
end end
end end
end end