# Refactor sketchup-ruby code

**URL:** <https://www.ruby-forum.com/t/refactor-sketchup-ruby-code/174918>\
**Category:** Ruby\
**Created:** [September 4, 2009, 3:13am UTC](https://www.ruby-forum.com/t/refactor-sketchup-ruby-code/174918 "2009-09-04T03:13:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@jim](https://www.ruby-forum.com/u/jim)\
**Post date:** [September 4, 2009, 3:13am UTC](https://www.ruby-forum.com/t/refactor-sketchup-ruby-code/174918/1 "2009-09-04T03:13:36Z")

</div>

Hello,

I need help in understanding how I can factor out some code I posted  
here:

> **[Google Sites: Sign-in](https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fsites.google.com%2Fsite%2Fsites%2Fsystem%2Ferrors%2FWebspaceNotFound%3Fpath%3D%2Fjimfoltz%2Fother-stuff&followup=https%3A%2F%2Fsites.google.com%2Fsite%2Fsites%2Fsystem%2Ferrors%2FWebspaceNotFound%3Fpath%3D%2Fjimfoltz%2Fother-stuff&ifkv=AeDOFXgsajrb81nVSJ60BvNin8N9lZEcxeJQ3MextquUFCVP5iCwG5RgHTaxZPKF44GTDYNFXpZDXg&passive=1209600&service=jotspot&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S-1979283456%3A1690665952427599)**
>
> Access Google Sites with a personal Google account or Google Workspace account (for business use).

I’m a novice but I am experimenting with sketchup observers, and the  
code near the top has a lot redundancy.

The first thing I want to understand is how I can factor out this  
section:

{|m| self.class.send(:define\_method, m) {|\*a| @c+= 1;puts “#{@c}:#{m}:#  
{ a.inspect }” } }

so it only needs edited in a single place, instead of once for each  
observer.

Thanks. Any other constructive comments are appreciated.
