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

#path, #valid?

Constructor Details

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

Returns a new instance of ProxyProperty.



123
124
125
126
# File 'lib/git-ds/model/property.rb', line 123

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.



122
123
124
# File 'lib/git-ds/model/property.rb', line 122

def obj_class
  @obj_class
end

Instance Method Details

#get(model, parent_path) ⇒ Object

Instantiate object from path stored in property.



138
139
140
141
# File 'lib/git-ds/model/property.rb', line 138

def get(model, parent_path)
  path = super model, parent_path
  @obj_class.new(model, path) if path && (not path.empty?)
end

#set(model, parent_path, obj) ⇒ Object

Write path of object to property.



131
132
133
# File 'lib/git-ds/model/property.rb', line 131

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