diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ayk/options.rb | 42 |
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 |