Class: SonJay::ObjectModel::Content::ContentWithExtra
- Inherits:
-
Abstract
- Object
- Abstract
- SonJay::ObjectModel::Content::ContentWithExtra
show all
- Defined in:
- lib/son_jay/object_model/content/content_with_extra.rb
Instance Attribute Summary
Attributes inherited from Abstract
#model_properties
Instance Method Summary
collapse
Methods inherited from Abstract
#[], #[]=, #fetch, #initialize, #load_data, #load_property, #to_json
Instance Method Details
#clone ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/son_jay/object_model/content/content_with_extra.rb', line 32
def clone
new_copy = super
if (defined? @extra) && (! new_copy.frozen?)
p new_copy.frozen?
new_copy.instance_variable_set :@extra, @extra.clone
end
new_copy
end
|
#dup ⇒ Object
26
27
28
29
30
|
# File 'lib/son_jay/object_model/content/content_with_extra.rb', line 26
def dup
new_copy = super
new_copy.instance_variable_set :@extra, @extra.dup if defined? @extra
new_copy
end
|
#each ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/son_jay/object_model/content/content_with_extra.rb', line 11
def each
@data.each do |(name, value)|
yield name, value
end
@extra.each do |(name, value)|
yield name, value
end
end
|
7
8
9
|
# File 'lib/son_jay/object_model/content/content_with_extra.rb', line 7
def
@extra ||= ObjectModel::ContentData.new
end
|
#freeze ⇒ Object
20
21
22
23
24
|
# File 'lib/son_jay/object_model/content/content_with_extra.rb', line 20
def freeze
super
@extra.freeze
self
end
|
#to_h ⇒ Object
41
42
43
44
45
|
# File 'lib/son_jay/object_model/content/content_with_extra.rb', line 41
def to_h
.empty? ?
@data.dup :
.hash_merge( @data )
end
|