Class: CouchRest::Model::CastedArray
- Inherits:
-
Array
- Object
- Array
- CouchRest::Model::CastedArray
show all
- Includes:
- CastedBy, Dirty
- Defined in:
- lib/couchrest/model/casted_array.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Dirty
#couchrest_attribute_will_change!, #couchrest_parent_will_change!, #use_dirty?
Methods included from CastedBy
#base_doc, #base_doc?
Constructor Details
#initialize(array, property, parent = nil) ⇒ CastedArray
Returns a new instance of CastedArray.
12
13
14
15
16
|
# File 'lib/couchrest/model/casted_array.rb', line 12
def initialize(array, property, parent = nil)
self.casted_by_property = property
self.casted_by = parent unless parent.nil?
super(array)
end
|
Instance Attribute Details
#casted_by_property ⇒ Object
Returns the value of attribute casted_by_property.
10
11
12
|
# File 'lib/couchrest/model/casted_array.rb', line 10
def casted_by_property
@casted_by_property
end
|
Instance Method Details
#<<(obj) ⇒ Object
20
21
22
|
# File 'lib/couchrest/model/casted_array.rb', line 20
def << obj
super(instantiate_and_cast(obj))
end
|
#[]=(index, obj) ⇒ Object
32
33
34
35
36
|
# File 'lib/couchrest/model/casted_array.rb', line 32
def []= index, obj
value = instantiate_and_cast(obj, false)
couchrest_parent_will_change! if use_dirty? && value != self[index]
super(index, value)
end
|
#build(*args) ⇒ Object
63
64
65
66
67
|
# File 'lib/couchrest/model/casted_array.rb', line 63
def build(*args)
obj = casted_by_property.build(*args)
self.push(obj)
obj
end
|
#clear ⇒ Object
48
49
50
51
|
# File 'lib/couchrest/model/casted_array.rb', line 48
def clear
couchrest_parent_will_change! if use_dirty? && self.length > 0
super
end
|
#delete(obj) ⇒ Object
53
54
55
56
|
# File 'lib/couchrest/model/casted_array.rb', line 53
def delete(obj)
couchrest_parent_will_change! if use_dirty? && self.length > 0
super(obj)
end
|
#delete_at(index) ⇒ Object
58
59
60
61
|
# File 'lib/couchrest/model/casted_array.rb', line 58
def delete_at(index)
couchrest_parent_will_change! if use_dirty? && self.length > 0
super(index)
end
|
#pop ⇒ Object
38
39
40
41
|
# File 'lib/couchrest/model/casted_array.rb', line 38
def pop
couchrest_parent_will_change! if use_dirty? && self.length > 0
super
end
|
#push(obj) ⇒ Object
24
25
26
|
# File 'lib/couchrest/model/casted_array.rb', line 24
def push(obj)
super(instantiate_and_cast(obj))
end
|
#shift ⇒ Object
43
44
45
46
|
# File 'lib/couchrest/model/casted_array.rb', line 43
def shift
couchrest_parent_will_change! if use_dirty? && self.length > 0
super
end
|
#unshift(obj) ⇒ Object
28
29
30
|
# File 'lib/couchrest/model/casted_array.rb', line 28
def unshift(obj)
super(instantiate_and_cast(obj))
end
|