Module: SwingSupport::Extensions::Attributes
- Defined in:
- lib/swing_support/extensions/attributes.rb
Overview
Module allows including classes to receive attribute values in an opts Hash and sets those attributes after object initialization
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#attach_to(parent) ⇒ Object
Proper way to add generic component to its parent.
-
#post_process(opts) ⇒ Object
Post-processing (non-setter) options given to initialize You need to delete processed/consumed options from given Hash.
Class Method Details
.included(host) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/swing_support/extensions/attributes.rb', line 6 def self.included host host.send :extend, ClassMethods host.instance_eval do # attr_setter :font, :tool_tip_text, :enabled alias :new_without_attributes :new alias :new :new_with_attributes end end |
Instance Method Details
#attach_to(parent) ⇒ Object
Proper way to add generic component to its parent
22 23 24 |
# File 'lib/swing_support/extensions/attributes.rb', line 22 def attach_to parent parent.add self if parent end |
#post_process(opts) ⇒ Object
Post-processing (non-setter) options given to initialize You need to delete processed/consumed options from given Hash
17 18 19 |
# File 'lib/swing_support/extensions/attributes.rb', line 17 def post_process opts attach_to opts.delete(:parent) end |