Module: Druthers::Def

Defined in:
lib/druthers/def.rb

Instance Method Summary collapse

Instance Method Details

#def_druthers(*keys) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/druthers/def.rb', line 6

def def_druthers(*keys)
  include Support
  keys.each do |ea|
    fail 'key names must be alphanumeric' unless ea.to_s =~ Druthers::VALID_METHOD_NAME
    class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def self.#{ea}=(value)
        self.set_druther(:#{ea}, value)
      end unless respond_to?(:#{ea}=)
      def self.#{ea}
        get_druther(:#{ea})
      end unless respond_to?(:#{ea})
    RUBY
  end
end