Module: Cura::Attributes::HasAttributes
- Included in:
- Cura::Adapter, Cura::Application, HasColors, HasCoordinates, HasDimensions, HasFocusability, HasOffsets, HasOrientation, HasRoot, HasSideAttributes, Color, Component::Base, Component::Label, Event::Base, Event::Dispatcher, FocusController, Offsets
- Defined in:
- lib/cura/attributes/has_attributes.rb
Overview
Adds the ‘update_attributes` method.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Object
Initialize this object by optionally updating attributes with a Hash.
-
#update_attributes(attributes = {}) ⇒ Hash
Update any attributes on this object.
Class Method Details
.included(base) ⇒ Object
38 39 40 |
# File 'lib/cura/attributes/has_attributes.rb', line 38 def included(base) base.extend(ClassMethods) end |
Instance Method Details
#initialize(attributes = {}) ⇒ Object
Initialize this object by optionally updating attributes with a Hash.
47 48 49 50 51 |
# File 'lib/cura/attributes/has_attributes.rb', line 47 def initialize(attributes={}) update_attributes(attributes) super end |
#update_attributes(attributes = {}) ⇒ Hash
Update any attributes on this object.
57 58 59 60 61 |
# File 'lib/cura/attributes/has_attributes.rb', line 57 def update_attributes(attributes={}) attributes = convert_attributes(attributes) attributes.each { |name, value| send("#{name}=", value) } end |