Module: Mameconf::ClassMethods
- Defined in:
- lib/mameconf.rb
Instance Attribute Summary collapse
-
#mameconf_attr_names ⇒ Object
Returns the value of attribute mameconf_attr_names.
Instance Method Summary collapse
Instance Attribute Details
#mameconf_attr_names ⇒ Object
Returns the value of attribute mameconf_attr_names.
24 25 26 |
# File 'lib/mameconf.rb', line 24 def mameconf_attr_names @mameconf_attr_names end |
Instance Method Details
#mameconf(name, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mameconf.rb', line 30 def mameconf(name, ={}) mameconf_attr_names << name default_value = [:default] class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} if !instance_variables.include?(:@#{name}) @#{name} ||= #{default_value.inspect} end @#{name} end def #{name}=(val) @#{name} = val end def to_hash ret = {} self.class.mameconf_attr_names.each do |attr| attr_sym = attr.to_sym ret[attr_sym] = self.__send__(attr_sym) end ret end RUBY end |