Class: StrokeDB::DocumentReferenceValue

Inherits:
String show all
Defined in:
lib/strokedb/document/slot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from String

#/, #blank?, #camel_case, #constantize, #demodulize, #ends_with?, #lines, #modulize, #plural, #singular, #snake_case, #stroke_diff, #stroke_merge, #stroke_patch, #tableize, #underscore, #unindent!

Constructor Details

#initialize(str, doc, __cached_value = nil) ⇒ DocumentReferenceValue

Returns a new instance of DocumentReferenceValue.



55
56
57
58
59
# File 'lib/strokedb/document/slot.rb', line 55

def initialize(str, doc, __cached_value = nil)
  @str, @doc = str, doc
  @cached_value = __cached_value
  super(str)
end

Instance Attribute Details

#docObject

Returns the value of attribute doc.



54
55
56
# File 'lib/strokedb/document/slot.rb', line 54

def doc
  @doc
end

#strObject (readonly) Also known as: to_raw, to_s

Returns the value of attribute str.



53
54
55
# File 'lib/strokedb/document/slot.rb', line 53

def str
  @str
end

Instance Method Details

#==(v) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/strokedb/document/slot.rb', line 76

def ==(v)
  case v
  when DocumentReferenceValue
    v.str == str
  when Document
    v == self
  else
    str == v
  end
end

#inspectObject



70
71
72
# File 'lib/strokedb/document/slot.rb', line 70

def inspect
  "#<DocRef #{self[0,5]}..>"
end

#loadObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/strokedb/document/slot.rb', line 60

def load
  case self
  when VERSIONREF
    if doc.head?
      @cached_value || @cached_value = doc.store.find($1) || self
    else
      @cached_value || @cached_value = doc.store.find($1,$2) || self
    end
  end
end