summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2009-10-08 22:31:55 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-06-30 08:08:47 +0200
commit72a8a4e7aeff0fc93d2199c4d0cd25e3dffc1196 (patch)
tree7e7c1b2fdeb740c3032f9b1763afd5a2875d47e7 /lib
parentc829d9395bc1152fac97ed16f2fcf6ed93fb60ee (diff)
downloadayk-72a8a4e7aeff0fc93d2199c4d0cd25e3dffc1196.zip
ayk-72a8a4e7aeff0fc93d2199c4d0cd25e3dffc1196.tar.gz
add Optioned module
Diffstat (limited to 'lib')
-rw-r--r--lib/ayk/options.rb42
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/ayk/options.rb b/lib/ayk/options.rb
index 5650609..5b34481 100644
--- a/lib/ayk/options.rb
+++ b/lib/ayk/options.rb
@@ -32,6 +32,8 @@ module AYK
yield(self) if block_given?
end
#
+ attr_reader :name
+ #
# Shortcut for instance_eval
def dsl &block
instance_eval(&block) if block
@@ -142,26 +144,22 @@ module AYK
def pretty_print q; q.pp_hash @hash end
end
#
-# # extend your class with this
-# module Optioned
-# def self.included(into)
-# into.extend(SingletonMethods)
-#
-# snaked = into.name.split('::').last
-# snaked = snaked.gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
-#
-# options = Innate.options.sub(snaked)
-# into.instance_variable_set(:@options, options)
-# end
-#
-# module SingletonMethods
-# attr_reader :options
-# end
-#
-# private
-#
-# def options
-# self.class.options
-# end
-# end
+ # extend your class with this
+ module Optioned
+ def self.included(into)
+ into.extend(SingletonMethods)
+ snaked = into.name.split('::').last
+ snaked = snaked.gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
+ into.instance_variable_set :@options, Options.new(snaked)
+ end
+ #
+ module SingletonMethods
+ attr_reader :options
+ end
+ #
+ private
+ def options
+ self.class.options
+ end
+ end
end