Skip to content

Commit 64876cf

Browse files
abrissegkellogg
authored andcommitted
Do not use Array() to uses to_ary which has been deprecated (#351)
1 parent eec1a43 commit 64876cf

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

lib/rdf/mixin/enumerable.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def validate!
122122
# @see #each_statement
123123
# @see #enum_statement
124124
def statements(**options)
125-
Array(enum_statement)
125+
enum_statement.to_a
126126
end
127127

128128
##
@@ -311,7 +311,7 @@ def subjects(unique: true)
311311
unless unique
312312
enum_statement.map(&:subject) # TODO: optimize
313313
else
314-
Array(enum_subject)
314+
enum_subject.to_a
315315
end
316316
end
317317

@@ -376,7 +376,7 @@ def predicates(unique: true)
376376
unless unique
377377
enum_statement.map(&:predicate) # TODO: optimize
378378
else
379-
Array(enum_predicate)
379+
enum_predicate.to_a
380380
end
381381
end
382382

@@ -441,7 +441,7 @@ def objects(unique: true)
441441
unless unique
442442
enum_statement.map(&:object) # TODO: optimize
443443
else
444-
Array(enum_object)
444+
enum_object.to_a
445445
end
446446
end
447447

@@ -514,7 +514,7 @@ def terms(unique: true)
514514
flatten.
515515
compact
516516
else
517-
Array(enum_term)
517+
enum_term.to_a
518518
end
519519
end
520520

@@ -759,7 +759,7 @@ def dump(*args, **options)
759759
# @overload #to_writer
760760
# Implements #to_writer for each available instance of {RDF::Writer},
761761
# based on the writer symbol.
762-
#
762+
#
763763
# @return [String]
764764
# @see {RDF::Writer.sym}
765765
def method_missing(meth, *args)
@@ -780,7 +780,7 @@ def method_missing(meth, *args)
780780
end
781781

782782
##
783-
# @note this instantiates an writer; it could probably be done more
783+
# @note this instantiates an writer; it could probably be done more
784784
# efficiently by refactoring `RDF::Reader` and/or `RDF::Format` to expose
785785
# a list of valid format symbols.
786786
def respond_to_missing?(name, include_private = false)

spec/mixin_enumerable_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@
7979
end
8080
end
8181

82+
context "Not using any deprecated method" do
83+
%w(subjects predicates objects statements triples quads).each do |method|
84+
it "##{method}" do
85+
expect { subject.send(method.to_sym).to_a }.not_to output.to_stderr
86+
end
87+
end
88+
end
89+
8290
context "Obtaining all unique values" do
8391
%w(subjects predicates objects).each do |method|
8492
it "##{method}" do

0 commit comments

Comments
 (0)