lib/swing_support/extensions/attributes.rb in swing-0.1.5 vs lib/swing_support/extensions/attributes.rb in swing-0.1.7
- old
+ new
@@ -12,10 +12,20 @@
alias :new_without_attributes :new
alias :new :new_with_attributes
end
end
+ # Post-processing (non-setter) options given to initialize
+ def post_process opts
+ attach_to opts[:parent]
+ end
+
+ # Proper way to add generic component to its parent
+ def attach_to parent
+ parent.add self if parent
+ end
+
module ClassMethods
def attributes
@attributes ||= (superclass.attributes.dup rescue {})
end
@@ -49,21 +59,11 @@
end.compact
# yield opts if block_given?
attributes.each { |(name, value)| component.send "#{name}=", *value }
# Post-process non-setter opts (setter opts are already consumed by now)
- post_process component, opts
+ component.post_process opts
component
- end
-
- # Post-processing (non-setter) options given to initialize
- def post_process component, opts
- add_component component, opts[:parent]
- end
-
- # Proper way to add this component to its parent
- def add_component component, parent
- parent.add component if parent
end
end
end
end
end