Skip to content

Commit 54fce8c

Browse files
committed
Eliminate a warning when calling File.open with keyword arguments.
1 parent 3d4c491 commit 54fce8c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/tzinfo/ruby_core_support.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,19 @@ def self.force_encoding(str, encoding)
137137
def self.open_file(file_name, mode, opts, &block)
138138
File.open(file_name, mode, &block)
139139
end
140-
else
140+
elsif RUBY_VERSION =~ /\A1\.9\./
141141
def self.open_file(file_name, mode, opts, &block)
142142
File.open(file_name, mode, opts, &block)
143143
end
144+
else
145+
# Evaluate method as a string because **opts isn't valid syntax prior to
146+
# Ruby 2.0.
147+
eval(<<-EOF
148+
def self.open_file(file_name, mode, opts, &block)
149+
File.open(file_name, mode, **opts, &block)
150+
end
151+
EOF
152+
)
144153
end
145154

146155

0 commit comments

Comments
 (0)