classXを使うと何がうれしいか

http://d.hatena.ne.jp/walf443/20080520/1211239672

で触れた宣言的なアクセサをGitHubPostRecieverに試しに適用してみた

+      has :host, :is => :ro, :kind_of => String, :required => true
+      has :port, :is => :ro, :kind_of => Integer, :default => 6667
+      has :nick, :is => :ro, :kind_of => String, :required => true
+      has :user, :is => :ro, :kind_of => String, :lazy => true, :default => proc {|mine| mine.nick }
+      has :real, :is => :ro, :kind_of => String, :lazy => true, :default => proc {|mine| mine.nick }
+      has :template, :is => :ro, :kind_of => String, :required => true
+
       def run method, json
-        json['commits'].each do |sha, commit|
-          CommitPingBot.new(@config['host'], @config['port'], {
-            'nick', @config['nick'],
-            'user', @config['user'],
-            'real', @config['real'],
-          }).run("##{method}", View.new(@config['template'], commit).result)
+        json['commits'].reverse.each do |sha, commit|
+          CommitPingBot.new(@host, @port, {
+            'nick' => @nick,
+            'user' => @user,
+            'real' => @real,
+          }).run("##{method}", View.new(@template, commit).result)
         end
       end
     end

元々のクラスだと、@configの中にどんな設定ができるのかということがわかりづらかったのですが、アクセサにしてしまえば、どの設定が必須なのかとかどんな値を指定すれば良いかが一目瞭然ですね。