Module: AttrSetter::ClassMethods
- Defined in:
- lib/swing_support/extensions/attr_setter.rb
Instance Method Summary collapse
-
#attr_setter(*new_attributes) ⇒ Object
Adds settable attributes for a given class, possibly with defaults If defaults are given for attributes, they should be put at the end (as opts).
- #attributes ⇒ Object
Instance Method Details
#attr_setter(*new_attributes) ⇒ Object
Adds settable attributes for a given class, possibly with defaults If defaults are given for attributes, they should be put at the end (as opts)
42 43 44 45 46 47 48 49 |
# File 'lib/swing_support/extensions/attr_setter.rb', line 42 def attr_setter *new_attributes if new_attributes.last.is_a? Hash # Some attributes are given with defaults new_attributes_with_defaults = new_attributes.pop new_attributes_with_defaults.each { |name, default| attributes[name] = default } end new_attributes.each { |name| attributes[name] = nil } end |
#attributes ⇒ Object
36 37 38 |
# File 'lib/swing_support/extensions/attr_setter.rb', line 36 def attributes @attributes ||= (superclass.attributes.dup rescue {}) end |