Sha256: b9a149547828ab765c36814d31baa69b62b52932cf1768d7fe5509d4da12ac07
Contents?: true
Size: 781 Bytes
Versions: 2
Compression:
Stored size: 781 Bytes
Contents
module Rlyeh module Settings def self.included(base) base.extend ClassMethods end module ClassMethods def settings self end def set(option, value = nil, &block) if option.respond_to?(:each) option.each { |k, v| set k, v } return self end setter = proc { |v| set option, v } getter = block ? block : proc { value } Rlyeh::Utils.singleton_class(self).class_eval do define_method "#{option}=", &setter if setter define_method "#{option}", &getter if getter class_eval "def #{option}?; !!#{option}; end" unless method_defined?("#{option}?") end end self end def settings self.class.settings end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rlyeh-0.1.1 | lib/rlyeh/settings.rb |
rlyeh-0.0.2 | lib/rlyeh/settings.rb |