Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

accessor options with a seperate setter

  • Loading branch information...
commit 9da2be9ec206cb417ea08e4ef728d27d506d79ba 1 parent 90eccbb
Gibheer authored January 28, 2013

Showing 1 changed file with 19 additions and 0 deletions. Show diff stats Hide diff stats

  1. 19  lib/class_options/accessor_options.rb
19  lib/class_options/accessor_options.rb
... ...
@@ -0,0 +1,19 @@
  1
+module ClassOptions
  2
+  class AccessorOptions < Options
  3
+    def accept_options(*new_options)
  4
+      super
  5
+      new_options.each {|option| define_option_accessor(option) }
  6
+    end 
  7
+
  8
+    protected
  9
+
  10
+    def define_option_accessor(option)
  11
+      class_eval <<-RUBY, __FILE__, __LINE__ + 1
  12
+        def self.#{option}=(value)           # def self.primitive=(value)
  13
+          self.#{option}(value)              #   self.primitive(value)
  14
+        end                                  # end
  15
+      RUBY
  16
+    end
  17
+    end
  18
+  end
  19
+end

0 notes on commit 9da2be9

Please sign in to comment.
Something went wrong with that request. Please try again.