Class: Waves::Configurations::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/waves/runtime/configuration.rb

Direct Known Subclasses

Default

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Get the value of the given attribute. Typically, you wouldn’t use this directly.



14
# File 'lib/waves/runtime/configuration.rb', line 14

def self.[]( name ) ; send "_#{name}" rescue nil ; end

.[]=(name, val) ⇒ Object

Set the given attribute with the given value. Typically, you wouldn’t use this directly.



8
9
10
# File 'lib/waves/runtime/configuration.rb', line 8

def self.[]=( name, val )
  meta_def("_#{name}") { val }
end

.attribute(name) ⇒ Object

Define a new attribute. After calling this, you can get and set the value using the attribute name as the method



18
19
20
21
22
23
24
# File 'lib/waves/runtime/configuration.rb', line 18

def self.attribute( name )
  meta_def(name) do |*args|
    raise ArgumentError.new('Too many arguments.') if args.length > 1
    args.length == 1 ? self[ name ] = args.first : self[ name ]
  end
  self[ name ] = nil
end

.attributes(*names) ⇒ Object



26
27
28
# File 'lib/waves/runtime/configuration.rb', line 26

def self.attributes( *names )
  names.each { |name| attribute( name ) }
end