Class: Rave::Models::Element
- Includes:
- Rave::Mixins::ObjectFactory
- Defined in:
- lib/models/element.rb
Overview
An element within a document. (abstract factory)
Direct Known Subclasses
Defined Under Namespace
Classes: Form, Gadget, Image, InlineBlip
Constant Summary collapse
- JAVA_CLASS =
"com.google.wave.api.FormElement"
Constants included from Rave::Mixins::ObjectFactory
Rave::Mixins::ObjectFactory::WILDCARD
Constants inherited from Component
Component::GENERATED_PATTERN, Component::GENERATED_PREFIX
Instance Attribute Summary
Attributes included from Rave::Mixins::ObjectFactory
Attributes inherited from Component
Instance Method Summary collapse
-
#get(key, default = nil) ⇒ Object
(also: #[])
Gets the value of an element property.
-
#initialize(properties = {}) ⇒ Element
constructor
A new instance of Element.
-
#set(key, value) ⇒ Object
(also: #[]=)
Sets the value of an element property.
-
#to_json ⇒ Object
:nodoc:.
Methods included from Rave::Mixins::ObjectFactory
Methods inherited from Component
#generated?, #id, #to_s, #unique_id
Methods included from Rave::Mixins::Logger
Constructor Details
#initialize(properties = {}) ⇒ Element
Returns a new instance of Element.
10 11 12 13 |
# File 'lib/models/element.rb', line 10 def initialize(properties = {}) super(:id => '') # TODO: Don't actually have IDs, as such. Bad inheritance from Component? @properties = properties end |
Instance Method Details
#get(key, default = nil) ⇒ Object Also known as: []
Gets the value of an element property.
16 17 18 19 20 21 22 |
# File 'lib/models/element.rb', line 16 def get(key, default = nil) if @properties.has_key? key @properties[key] else default end end |
#set(key, value) ⇒ Object Also known as: []=
Sets the value of an element property.
25 26 27 |
# File 'lib/models/element.rb', line 25 def set(key, value) @properties[key] = value end |
#to_json ⇒ Object
:nodoc:
35 36 37 38 39 40 41 |
# File 'lib/models/element.rb', line 35 def to_json # :nodoc: { 'javaClass' => JAVA_CLASS, 'properties' => @properties, 'type' => type, }.to_json end |