lib/tori/file.rb in tori-0.7.2 vs lib/tori/file.rb in tori-0.8.0
- old
+ new
@@ -1,5 +1,7 @@
+require 'ruby2_keywords'
+
module Tori
class File
def initialize(model, title: nil, from: nil, to: nil, &block)
@model = model
@title = title.kind_of?(String) ? title.to_sym : title
@@ -63,14 +65,26 @@
def respond_to_missing?(sym, include_private)
backend.respond_to?(sym, include_private)
end
- def method_missing(sym, *args, &block)
- if respond_to_missing?(sym, false)
- backend.__send__ sym, name, *args, &block
- else
- raise NameError, "undefined method `#{sym}' for #{backend}"
+ if RUBY_VERSION < "2.7"
+ ruby2_keywords def method_missing(sym, *args, &block)
+ if respond_to_missing?(sym, false)
+ backend.__send__ sym, name, *args, &block
+ else
+ raise NameError, "undefined method `#{sym}' for #{backend}"
+ end
end
+ else
+ eval <<~'RUBY'
+ def method_missing(sym, ...)
+ if respond_to_missing?(sym, false)
+ backend.__send__(sym, name, ...)
+ else
+ raise NameError, "undefined method `#{sym}' for #{backend}"
+ end
+ end
+ RUBY
end
end
end