lib/alterout.rb in veils-0.3.0 vs lib/alterout.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
@@ -26,11 +26,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 AlterOut
def initialize(origin, methods = {})
@origin = origin
@methods = methods
@@ -45,13 +45,11 @@
method_missing(:to_json, options)
end
def method_missing(*args)
method = args[0]
- 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)
out =
if block_given?
@origin.__send__(*args) do |*a|
yield(*a)
end
@@ -61,10 +59,10 @@
out = @methods[method].call(out) if @methods.key?(method)
out
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