Class: GitDS::ProxyProperty
- Inherits:
-
PropertyDefinition
- Object
- PropertyDefinition
- GitDS::ProxyProperty
- Defined in:
- lib/git-ds/model/property.rb
Overview
A Property that is a link to a ModelItem class instance.
Instance Attribute Summary collapse
-
#obj_class ⇒ Object
readonly
Returns the value of attribute obj_class.
Attributes inherited from PropertyDefinition
#default_value, #name, #on_fs, #validation_block
Instance Method Summary collapse
-
#get(model, parent_path) ⇒ Object
Instantiate object from path stored in property.
-
#initialize(name, cls, fs = false, &block) ⇒ ProxyProperty
constructor
A new instance of ProxyProperty.
-
#set(model, parent_path, obj) ⇒ Object
Write path of object to property.
Methods inherited from PropertyDefinition
#convert_value, #path, #valid?
Constructor Details
#initialize(name, cls, fs = false, &block) ⇒ ProxyProperty
Returns a new instance of ProxyProperty.
172 173 174 175 |
# File 'lib/git-ds/model/property.rb', line 172 def initialize(name, cls, fs=false, &block) super name, nil, fs, &block @obj_class = cls end |
Instance Attribute Details
#obj_class ⇒ Object (readonly)
Returns the value of attribute obj_class.
171 172 173 |
# File 'lib/git-ds/model/property.rb', line 171 def obj_class @obj_class end |
Instance Method Details
#get(model, parent_path) ⇒ Object
Instantiate object from path stored in property.
187 188 189 190 191 |
# File 'lib/git-ds/model/property.rb', line 187 def get(model, parent_path) # the object path is stored in the property file obj_path = super model, parent_path @obj_class.new(model, obj_path) if obj_path && (not obj_path.empty?) end |
#set(model, parent_path, obj) ⇒ Object
Write path of object to property.
180 181 182 |
# File 'lib/git-ds/model/property.rb', line 180 def set(model, parent_path, obj) super model, parent_path, obj.path end |