Skip to content

Commit 29fd9b5

Browse files
committed
Update options calling sequences to be compatible with Ruby 3.0.
1 parent d98e9c2 commit 29fd9b5

1 file changed

Lines changed: 24 additions & 35 deletions

File tree

lib/rdf/virtuoso/query.rb

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Query < RDF::Query
2929
# @param [Hash{Symbol => Object}] options
3030
# @return [Query]
3131
# @see http://www.w3.org/TR/rdf-sparql-query/#ask
32-
def self.ask(options = {})
33-
self.new(:ask, options)
32+
def self.ask(**options)
33+
self.new(:ask, **options)
3434
end
3535

3636
##
@@ -40,9 +40,8 @@ def self.ask(options = {})
4040
# @param [Hash{Symbol => Object}] options
4141
# @return [Query]
4242
# @see http://www.w3.org/TR/rdf-sparql-query/#select
43-
def self.select(*variables)
44-
options = variables.last.is_a?(Hash) ? variables.pop : {}
45-
self.new(:select, options).select(*variables)
43+
def self.select(*variables, **options)
44+
self.new(:select, **options).select(*variables)
4645
end
4746

4847
##
@@ -52,9 +51,8 @@ def self.select(*variables)
5251
# @param [Hash{Symbol => Object}] options
5352
# @return [Query]
5453
# @see http://www.w3.org/TR/rdf-sparql-query/#describe
55-
def self.describe(*variables)
56-
options = variables.last.is_a?(Hash) ? variables.pop : {}
57-
self.new(:describe, options).describe(*variables)
54+
def self.describe(*variables, **options)
55+
self.new(:describe, **options).describe(*variables)
5856
end
5957

6058
##
@@ -64,9 +62,8 @@ def self.describe(*variables)
6462
# @param [Hash{Symbol => Object}] options
6563
# @return [Query]
6664
# @see http://www.w3.org/TR/rdf-sparql-query/#construct
67-
def self.construct(*patterns)
68-
options = patterns.last.is_a?(Hash) ? patterns.pop : {}
69-
self.new(:construct, options).construct(*patterns) # FIXME
65+
def self.construct(*patterns, **options)
66+
self.new(:construct, **options).construct(*patterns) # FIXME
7067
end
7168

7269
##
@@ -76,50 +73,42 @@ def self.construct(*patterns)
7673
# @param [Hash{Symbol => Object}] options
7774
# @return [Query]
7875
# @see http://www.w3.org/Submission/SPARQL-Update/
79-
def self.insert_data(*patterns)
80-
# options = variables.last.is_a?(Hash) ? variables.pop : {}
81-
options = patterns.last.is_a?(Hash) ? patterns.pop : {}
82-
self.new(:insert_data, options).insert_data(*patterns)
76+
def self.insert_data(*patterns, **options)
77+
self.new(:insert_data, **options).insert_data(*patterns)
8378
end
8479

85-
def self.insert(*patterns)
86-
options = patterns.last.is_a?(Hash) ? patterns.pop : {}
87-
self.new(:insert, options).insert(*patterns)
80+
def self.insert(*patterns, **options)
81+
self.new(:insert, **options).insert(*patterns)
8882
end
8983

90-
def self.delete_data(*patterns)
91-
options = patterns.last.is_a?(Hash) ? patterns.pop : {}
92-
self.new(:delete_data, options).delete_data(*patterns)
84+
def self.delete_data(*patterns, **options)
85+
self.new(:delete_data, **options).delete_data(*patterns)
9386
end
9487

95-
def self.delete(*patterns)
96-
options = patterns.last.is_a?(Hash) ? patterns.pop : {}
97-
self.new(:delete, options).delete(*patterns)
88+
def self.delete(*patterns, **options)
89+
self.new(:delete, **options).delete(*patterns)
9890
end
9991

100-
def self.create(*variables)
101-
options = variables.last.is_a?(Hash) ? variables.pop : {}
102-
self.new(:create, options).create(variables.first)
92+
def self.create(*variables, **options)
93+
self.new(:create, **options).create(variables.first)
10394
end
10495

105-
def self.drop(*variables)
106-
options = variables.last.is_a?(Hash) ? variables.pop : {}
107-
self.new(:drop, options).drop(variables.first)
96+
def self.drop(*variables, **options)
97+
self.new(:drop, **options).drop(variables.first)
10898
end
10999

110-
def self.clear(*variables)
111-
options = variables.last.is_a?(Hash) ? variables.pop : {}
112-
self.new(:clear, options).clear(variables.first)
100+
def self.clear(*variables, **options)
101+
self.new(:clear, **options).clear(variables.first)
113102
end
114103

115104
##
116105
# @param [Symbol, #to_s] form
117106
# @param [Hash{Symbol => Object}] options
118107
# @yield [query]
119108
# @yieldparam [Query]
120-
def initialize(form = :ask, options = {}, &block)
109+
def initialize(form = :ask, **options, &block)
121110
@form = form.respond_to?(:to_sym) ? form.to_sym : form.to_s.to_sym
122-
super([], options, &block)
111+
super([], **options, &block)
123112
end
124113

125114
##

0 commit comments

Comments
 (0)