From 992d232ed4dbb5953a1930ce06c2f7e27ee8dcb2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Sep 2026 18:44:56 +0000 Subject: [PATCH] Simplify block default passing in cattr and mattr The class_variable_defined? guard in the reader and writer already keeps the default block from running twice, so cattr and mattr can pass the block straight through instead of splitting writers. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01E2Njj4j1r9twkVcXsMySLW --- lib/core/facets/module/mattr.rb | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/core/facets/module/mattr.rb b/lib/core/facets/module/mattr.rb index d989f40e..f8782032 100644 --- a/lib/core/facets/module/mattr.rb +++ b/lib/core/facets/module/mattr.rb @@ -25,13 +25,7 @@ def cattr(*syms, &block) ##readers.concat( writers ) # writers also get readers cattr_reader(*readers, &block) - - if block - cattr_writer(*(writers - readers), &block) - cattr_writer(*(writers & readers)) - else - cattr_writer(*writers) - end + cattr_writer(*writers, &block) return readers + writers end @@ -170,12 +164,7 @@ def mattr(*syms, &block) writers = writers.collect{ |e| e.to_s.chomp('=').to_sym } ##readers.concat( writers ) # writers also get readers - if block - mattr_writer( *(writers - readers), &block ) - mattr_writer( *(writers & readers) ) - else - mattr_writer( *writers ) - end + mattr_writer( *writers, &block ) mattr_reader( *readers, &block ) return readers + writers