Permalink
Browse files

accessor options with a seperate setter

  • Loading branch information...
1 parent 90eccbb commit 9da2be9ec206cb417ea08e4ef728d27d506d79ba @Gibheer committed Jan 28, 2013
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/class_options/accessor_options.rb
@@ -0,0 +1,19 @@
+module ClassOptions
+ class AccessorOptions < Options
+ def accept_options(*new_options)
+ super
+ new_options.each {|option| define_option_accessor(option) }
+ end
+
+ protected
+
+ def define_option_accessor(option)
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
+ def self.#{option}=(value) # def self.primitive=(value)
+ self.#{option}(value) # self.primitive(value)
+ end # end
+ RUBY
+ end
+ end
+ end
+end

0 comments on commit 9da2be9

Please sign in to comment.