File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ module Schema
77 # @api private
88 class Trace < ::BasicObject
99 INVALID_PREDICATES = %i[ key? ] . freeze
10+ RESPOND_TO_MISSING_METHOD = ::Kernel . instance_method ( :respond_to_missing? )
1011
1112 include ::Dry ::Equalizer ( :compiler , :captures )
1213
@@ -86,12 +87,13 @@ def reduced_rule
8687 end
8788
8889 def respond_to_missing? ( meth , include_private = false )
89- super || ( meth . to_s . end_with? ( QUESTION_MARK ) && compuiler . support? ( meth ) )
90+ RESPOND_TO_MISSING_METHOD . bind_call ( self , meth , include_private ) ||
91+ ( meth . to_s . end_with? ( QUESTION_MARK ) && compiler . support? ( meth ) )
9092 end
9193
9294 # @api private
9395 def method_missing ( meth , *args , &block )
94- if meth . to_s . end_with? ( QUESTION_MARK )
96+ if ! meth . equal? ( :respond_to_missing? ) && meth . to_s . end_with? ( QUESTION_MARK )
9597 if ::Dry ::Schema ::Trace ::INVALID_PREDICATES . include? ( meth )
9698 ::Kernel . raise InvalidSchemaError , "#{ meth } predicate cannot be used in this context"
9799 end
Original file line number Diff line number Diff line change 3131 expect { trace . not_here } . to raise_error ( NoMethodError , /not_here/ )
3232 end
3333 end
34+
35+ describe "#respond_to?" do
36+ let ( :respond_to ) do
37+ Kernel . instance_method ( :respond_to? )
38+ end
39+
40+ it "returns true for predicates" do
41+ expect ( respond_to . bind_call ( trace , :eql? ) ) . to be ( true )
42+ end
43+
44+ it "returns false for other methods" do
45+ expect ( respond_to . bind_call ( trace , :not_here? ) ) . to be ( false )
46+ end
47+ end
3448end
You can’t perform that action at this time.
0 commit comments