Permalink
Browse files

remove abuse of ClassMethods and use extend

  • Loading branch information...
1 parent 297da3c commit 9b917b4996724ee67bb32be7debb815d3ba9cf17 @banister committed Jan 27, 2012
Showing with 14 additions and 19 deletions.
  1. +13 −18 lib/cls.rb
  2. +1 −1 spec/cls_spec.rb
View
@@ -1,26 +1,21 @@
module Cls
VERSION = "0.0.1"
- def self.included(base)
- base.send :extend, ClassMethods
- end
- module ClassMethods
- def takes(*args)
- define_initialize(args)
- end
+ def takes(*args)
+ define_initialize(args)
+ end
- def define_initialize(args)
- assignments = args.map { |a| "@#{a} = #{a}" }.join("\n")
- self.class_eval %{
- def initialize(#{args.join(", ")})
- #{assignments}
- end
- }
- end
+ def define_initialize(args)
+ assignments = args.map { |a| "@#{a} = #{a}" }.join("\n")
+ self.class_eval %{
+ def initialize(#{args.join(", ")})
+ #{assignments}
+ end
+ }
+ end
- def let(name, &block)
- define_method(name, &block)
- end
+ def let(name, &block)
+ define_method(name, &block)
end
end
View
@@ -1,7 +1,7 @@
require "cls"
class NamePresenter
- include Cls
+ extend Cls
attr_reader :name
takes(:name)
let(:yelled_name) { @name.upcase }

0 comments on commit 9b917b4

Please sign in to comment.