Module: ODDB::PersistenceMethods

Included in:
Address2, Persistence
Defined in:
src/util/persistence.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) oid (readonly)

Returns the value of attribute oid



32
33
34
# File 'src/util/persistence.rb', line 32

def oid
  @oid
end

- (Object) pointer

Returns the value of attribute pointer



33
34
35
# File 'src/util/persistence.rb', line 33

def pointer
  @pointer
end

- (Object) revision

Returns the value of attribute revision



33
34
35
# File 'src/util/persistence.rb', line 33

def revision
  @revision
end

Instance Method Details

- (Object) checkout



60
61
# File 'src/util/persistence.rb', line 60

def checkout
end

- (Object) data_origin(key)



41
42
43
# File 'src/util/persistence.rb', line 41

def data_origin(key)
  data_origins[key.to_s]
end

- (Object) data_origins



44
45
46
# File 'src/util/persistence.rb', line 44

def data_origins
  @data_origins ||= {}
end

- (Object) diff(values, app = nil)



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'src/util/persistence.rb', line 47

def diff(values, app=nil)
  #adjust_types(values, app)
  result = {}
  adjust_types(values, app).each { |key, value|
    if(self.respond_to?(key))
      oldval = self.send(key)
      if(oldval.nil? || undiffable?(oldval) || value != oldval)
        result.store(key, value)
      end
    end
  }
  result
end

- (Object) init(app)



34
35
# File 'src/util/persistence.rb', line 34

def init(app)
end

- (Object) nil_if_empty(value)



62
63
64
65
# File 'src/util/persistence.rb', line 62

def nil_if_empty(value)
  val = value.to_s.strip
  (val.empty?) ? nil : val
end

- (Object) parent(app)



66
67
68
# File 'src/util/persistence.rb', line 66

def parent(app)
  @pointer.parent.resolve(app)
end

- (Object) pointer_descr



69
70
71
# File 'src/util/persistence.rb', line 69

def pointer_descr
  self.class.to_s
end

- (Object) structural_ancestors(app)



36
37
38
39
40
# File 'src/util/persistence.rb', line 36

def structural_ancestors(app)
  if(@pointer)
    @pointer.ancestors.collect { |pointer| pointer.resolve(app) }
  end
end

- (Boolean) undiffable?(val)

Returns:

  • (Boolean)


72
73
74
# File 'src/util/persistence.rb', line 72

def undiffable?(val)
  defined?(val.class::DISABLE_DIFF) && val.class::DISABLE_DIFF
end

- (Object) update_values(values, origin = nil)



75
76
77
78
79
80
81
82
# File 'src/util/persistence.rb', line 75

def update_values(values, origin=nil)
  @revision = Time.now
  values.each { |key, value|
    key = key.to_s
    data_origins.store(key, origin)
    self.send(key + '=', value)
  }
end