Class: Rave::Models::Component
- Inherits:
-
Object
- Object
- Rave::Models::Component
- Includes:
- Rave::Mixins::Logger
- Defined in:
- lib/models/component.rb
Overview
A wave or wave component. This is an abstract class.
Constant Summary collapse
- GENERATED_PREFIX =
:nodoc: Prefixes blips and wavelets that are created by the robot.
'TBD'
- GENERATED_PATTERN =
:nodoc:
/^#{GENERATED_PREFIX}/
- @@last_id =
For generated components, this is a unique ID number for them.
0
Instance Attribute Summary collapse
-
#context ⇒ Object
writeonly
:nodoc: Allow context to set link to it.
Instance Method Summary collapse
-
#generated? ⇒ Boolean
Has this component been generated by the robot [Boolean].
-
#id ⇒ Object
ID [String].
-
#initialize(options = {}) ⇒ Component
constructor
:nodoc:.
-
#to_s ⇒ Object
Convert to string.
-
#unique_id ⇒ Object
Generate a unique id number (from 1) [Integer].
Methods included from Rave::Mixins::Logger
Constructor Details
#initialize(options = {}) ⇒ Component
:nodoc:
31 32 33 34 |
# File 'lib/models/component.rb', line 31 def initialize( = {}) # :nodoc: @id = [:id] or raise ArgumentError.new(":id option is required for #{self.class.name}") @context = [:context] end |
Instance Attribute Details
#context=(value) ⇒ Object (writeonly)
:nodoc: Allow context to set link to it.
13 14 15 |
# File 'lib/models/component.rb', line 13 def context=(value) @context = value end |
Instance Method Details
#generated? ⇒ Boolean
Has this component been generated by the robot [Boolean]
16 17 18 19 |
# File 'lib/models/component.rb', line 16 def generated? # :nodoc: # This is true for all components except Users, who would override this. not (@id =~ /^#{GENERATED_PREFIX}/).nil? end |
#id ⇒ Object
ID [String]
27 28 29 |
# File 'lib/models/component.rb', line 27 def id # :nodoc: @id.dup end |
#to_s ⇒ Object
Convert to string.
37 38 39 |
# File 'lib/models/component.rb', line 37 def to_s "#{self.class.name[/[^:]*$/]}:#{@id}" end |
#unique_id ⇒ Object
Generate a unique id number (from 1) [Integer]
22 23 24 |
# File 'lib/models/component.rb', line 22 def unique_id # :nodoc: @@last_id += 1 end |