Skip to content

Commit 53580b9

Browse files
Saup21claude
authored andcommitted
fix: correct Object#blank? and Object#present? polyfill implementations
Object#blank? was `!self`, ignoring objects that respond to empty?. Should be `respond_to?(:empty?) ? !!empty? : !self` to match active_support. Object#present? was `!!self`, which is always true for any non-nil/non-false object regardless of blank? — inconsistent with classes that override blank?. Should be `!blank?`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8a1273c commit 53580b9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/pact/support/core_ext.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def present? = !empty?
3636
end
3737

3838
class Object
39-
def blank? = !self
40-
def present? = !!self
39+
def blank? = respond_to?(:empty?) ? !!empty? : !self
40+
def present? = !blank?
4141
end
4242
end
4343

0 commit comments

Comments
 (0)