Class: GitDS::BinaryPropertyDefinition

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

Overview

A definition of a ModelItem property that stores binary data.

Instance Attribute Summary

Attributes inherited from PropertyDefinition

#default_value, #name, #on_fs, #validation_block

Instance Method Summary collapse

Methods inherited from PropertyDefinition

#convert_value, #initialize, #path

Constructor Details

This class inherits a constructor from GitDS::PropertyDefinition

Instance Method Details

#get(model, parent_path) ⇒ Object

Read value from ModelItem at path in Model.

This just returns the raw binary value of the property file contents.



144
145
146
# File 'lib/git-ds/model/property.rb', line 144

def get(model, parent_path)
  model.get_item(path(parent_path))
end

#set(model, parent_path, value) ⇒ Object

Write a raw binary value to ModelItem at path in Model.

Note: this returns the raw binary data as written to the Property BLOB.



153
154
155
156
# File 'lib/git-ds/model/property.rb', line 153

def set(model, parent_path, value)
  write(model, path(parent_path), value)
  value
end

#valid?(val) ⇒ Boolean

Raw binary property values are always valid if they are not nil

Returns:

  • (Boolean)


161
162
163
# File 'lib/git-ds/model/property.rb', line 161

def valid?(val)
  val != nil
end