Class: GitDS::ProxyProperty

Inherits:
PropertyDefinition show all
Defined in:
lib/git-ds/model/property.rb

Overview

A Property that is a link to a ModelItem class instance.

Instance Attribute Summary collapse

Attributes inherited from PropertyDefinition

#default_value, #name, #on_fs, #validation_block

Instance Method Summary collapse

Methods inherited from PropertyDefinition

#convert_value, #path, #valid?

Constructor Details

#initialize(name, cls, fs = false, &block) ⇒ ProxyProperty

Returns a new instance of ProxyProperty.



171
172
173
174
# File 'lib/git-ds/model/property.rb', line 171

def initialize(name, cls, fs=false, &block)
  super name, nil, fs, &block
  @obj_class = cls
end

Instance Attribute Details

#obj_classObject (readonly)

Returns the value of attribute obj_class.



170
171
172
# File 'lib/git-ds/model/property.rb', line 170

def obj_class
  @obj_class
end

Instance Method Details

#get(model, parent_path) ⇒ Object

Instantiate object from path stored in property.



186
187
188
189
# File 'lib/git-ds/model/property.rb', line 186

def get(model, parent_path)
  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.



179
180
181
# File 'lib/git-ds/model/property.rb', line 179

def set(model, parent_path, obj)
  super model, parent_path, obj.path
end