lib/unpiercable.rb in veils-0.3.0 vs lib/unpiercable.rb in veils-0.4.0
- old
+ new
@@ -1,10 +1,10 @@
# frozen_string_literal: true
# (The MIT License)
#
-# Copyright (c) 2020 Yegor Bugayenko
+# Copyright (c) 2020-2023 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -27,11 +27,11 @@
#
# For more information read
# {README}[https://github.com/yegor256/veils/blob/master/README.md] file.
#
# Author:: Yegor Bugayenko (yegor256@gmail.com)
-# Copyright:: Copyright (c) 2020 Yegor Bugayenko
+# Copyright:: Copyright (c) 2020-2023 Yegor Bugayenko
# License:: MIT
class Unpiercable
def initialize(origin, methods = {})
@origin = origin
@methods = methods
@@ -49,13 +49,11 @@
def method_missing(*args)
method = args[0]
if @methods.key?(method)
@methods[method]
else
- unless @origin.respond_to?(method)
- raise "Method #{method} is absent in #{@origin}"
- end
+ raise "Method #{method} is absent in #{@origin}" unless @origin.respond_to?(method)
if block_given?
@origin.__send__(*args) do |*a|
yield(*a)
end
else
@@ -63,10 +61,10 @@
end
end
end
def respond_to?(method, include_private = false)
- @origin.respond_to?(method, include_private) || @methods[method]
+ @origin.respond_to?(method, include_private) || @methods.key?(method)
end
def respond_to_missing?(_method, _include_private = false)
true
end