Class: RXCode::ArchivedObject
- Inherits:
-
Object
- Object
- RXCode::ArchivedObject
- Defined in:
- lib/rxcode/models/archived_object.rb
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
ARCHIVE ====================================================================================================.
-
#archived_object_id ⇒ Object
readonly
ARCHIVE OBJECT ID ==========================================================================================.
-
#model_object ⇒ Object
Returns the value of attribute model_object.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #array_of_model_objects_for_key(key) ⇒ Object
- #array_of_objects_for_key(key) ⇒ Object
-
#data ⇒ Object
DATA =======================================================================================================.
- #has_key?(key) ⇒ Boolean
-
#initialize(archive, archived_object_id) ⇒ ArchivedObject
constructor
A new instance of ArchivedObject.
- #model_object_for_key(key) ⇒ Object
- #object_for_key(key) ⇒ Object
Constructor Details
#initialize(archive, archived_object_id) ⇒ ArchivedObject
Returns a new instance of ArchivedObject.
5 6 7 8 |
# File 'lib/rxcode/models/archived_object.rb', line 5 def initialize(archive, archived_object_id) @archive = archive @archived_object_id = archived_object_id end |
Instance Attribute Details
#archive ⇒ Object (readonly)
ARCHIVE ====================================================================================================
12 13 14 |
# File 'lib/rxcode/models/archived_object.rb', line 12 def archive @archive end |
#archived_object_id ⇒ Object (readonly)
ARCHIVE OBJECT ID ==========================================================================================
16 17 18 |
# File 'lib/rxcode/models/archived_object.rb', line 16 def archived_object_id @archived_object_id end |
#model_object ⇒ Object
Returns the value of attribute model_object.
51 52 53 |
# File 'lib/rxcode/models/archived_object.rb', line 51 def model_object @model_object end |
Instance Method Details
#[](key) ⇒ Object
24 25 26 |
# File 'lib/rxcode/models/archived_object.rb', line 24 def [](key) data[key] end |
#array_of_model_objects_for_key(key) ⇒ Object
47 48 49 |
# File 'lib/rxcode/models/archived_object.rb', line 47 def array_of_model_objects_for_key(key) array_of_objects_for_key(key).map { |o| o.model_object } end |
#array_of_objects_for_key(key) ⇒ Object
37 38 39 |
# File 'lib/rxcode/models/archived_object.rb', line 37 def array_of_objects_for_key(key) self[key].map { |object_id| archive.object_with_id(object_id) } end |
#data ⇒ Object
DATA =======================================================================================================
20 21 22 |
# File 'lib/rxcode/models/archived_object.rb', line 20 def data @data ||= archive.object_hashes[self.archived_object_id] end |
#has_key?(key) ⇒ Boolean
28 29 30 |
# File 'lib/rxcode/models/archived_object.rb', line 28 def has_key?(key) data.has_key?(key) end |
#model_object_for_key(key) ⇒ Object
41 42 43 44 45 |
# File 'lib/rxcode/models/archived_object.rb', line 41 def model_object_for_key(key) if o = object_for_key(key) o.model_object end end |
#object_for_key(key) ⇒ Object
32 33 34 35 |
# File 'lib/rxcode/models/archived_object.rb', line 32 def object_for_key(key) object_id = self[key] archive.object_with_id(object_id) end |