Merge pull request #99 from dry-rb/73-deprecate-respond_to-predicate

[changelog]

version: unreleased
changed: "Deprecate respond_to? in favor of interface? (issue #73 closed via #99) (@solnic)"
This commit is contained in:
Peter Solnica 2022-10-14 05:56:55 +02:00 committed by GitHub
commit 91dabe8d49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -257,9 +257,10 @@ module Dry
format?(URI::RFC3986_Parser::RFC3986_URI, input)
end
def respond_to?(method, input)
def interface?(method, input)
input.respond_to?(method)
end
deprecate :respond_to?, :interface?
def predicate(name, &block)
define_singleton_method(name, &block)

View File

@ -1115,9 +1115,9 @@ RSpec.describe "predicates" do
end
end
describe :respond_to? do
describe :interface? do
let(:expression) do
->(*) { respond_to?(:awesome?) }
->(*) { interface?(:awesome?) }
end
describe "success" do

View File

@ -3,8 +3,8 @@
require "dry/logic/predicates"
RSpec.describe Dry::Logic::Predicates do
describe "#respond_to?" do
let(:predicate_name) { :respond_to? }
describe "#interface?" do
let(:predicate_name) { :interface? }
context "when value responds to method" do
let(:arguments_list) do