Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate respond_to? in favor of interface? #99

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/dry/logic/predicates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module Logic
module Predicates
# rubocop:disable Metrics/ModuleLength
module Methods
extend Dry::Core::Deprecations[:dry_logic]

def self.uuid_format(version)
::Regexp.new(<<~FORMAT.chomp, ::Regexp::IGNORECASE)
\\A[0-9A-F]{8}-[0-9A-F]{4}-#{version}[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}\\z
Expand Down Expand Up @@ -254,9 +256,10 @@ def uri_rfc3986?(input)
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)
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/builder/predicate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,9 @@
end
end

describe :respond_to? do
describe :interface? do
let(:expression) do
->(*) { respond_to?(:awesome?) }
->(*) { interface?(:awesome?) }
end

describe "success" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down