Class: GitDS::ProxyItemList
- Inherits:
-
ModelItemList
- Object
- ModelItemList
- GitDS::ProxyItemList
- Defined in:
- lib/git-ds/model/item_proxy.rb
Overview
A generic list of links to ModelItemClass instance of a specific class.
Example:
class a/1/name
class a/1/data
class a/2/name
class a/2/data
class b/1/a/1
class b/1/a/2
class b/$ID/a is a list of links to class a objects.
Instance Method Summary collapse
-
#add(parent, obj, on_fs = false) ⇒ Object
Add a link to ‘obj’ to the list.
-
#delete(ident) ⇒ Object
Delete a link from the list.
-
#initialize(cls, model, path) ⇒ ProxyItemList
constructor
A new instance of ProxyItemList.
Methods inherited from ModelItemList
#[], #count, #each, #first, #keys, #last
Constructor Details
#initialize(cls, model, path) ⇒ ProxyItemList
Returns a new instance of ProxyItemList.
104 105 106 107 108 |
# File 'lib/git-ds/model/item_proxy.rb', line 104 def initialize(cls, model, path) @true_class = cls @proxy_class = ModelItemClassProxy.new(cls) super @proxy_class, model, path end |
Instance Method Details
#add(parent, obj, on_fs = false) ⇒ Object
Add a link to ‘obj’ to the list.
113 114 115 116 117 |
# File 'lib/git-ds/model/item_proxy.rb', line 113 def add(parent, obj, on_fs=false) args = { :path => obj.path, :fs => on_fs } args[@true_class.ident_key] = obj.ident super parent, args end |
#delete(ident) ⇒ Object
Delete a link from the list. This does not delete the object that was linked to.
123 124 125 |
# File 'lib/git-ds/model/item_proxy.rb', line 123 def delete(ident) @model.delete_item @proxy_class.instance_path(@base_path, ident) end |