Class: ActiveAnnotations::Annotation

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/active_annotations/annotation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#internalObject (readonly)

Returns the value of attribute internal.



3
4
5
# File 'app/models/active_annotations/annotation.rb', line 3

def internal
  @internal
end

Instance Method Details

#annotationObject



62
63
64
65
# File 'app/models/active_annotations/annotation.rb', line 62

def annotation
  sync_annotation!
  self[:annotation]
end

#inspectObject



27
28
29
30
31
32
33
34
# File 'app/models/active_annotations/annotation.rb', line 27

def inspect
  internal_attrs = [:annotated_by, :annotated_at, :start_time, :end_time, :source, :content].collect { |attr|
    "#{attr}: #{internal.send(attr).inspect}"
  }
  inspection = (["uuid: #{uuid.inspect}"] + internal_attrs).compact.join(", ")
  hex_id = '%#016x' % (self.object_id << 1)
  "#<#{self.class}:#{hex_id} #{inspection}>"
end

#pretty_annotationObject



67
68
69
70
# File 'app/models/active_annotations/annotation.rb', line 67

def pretty_annotation
  sync_annotation!
  internal.to_jsonld(pretty_json: true)
end

#sync_annotation!Object



42
43
44
45
46
47
48
# File 'app/models/active_annotations/annotation.rb', line 42

def sync_annotation!
  if @internal_changed
    self[:annotation] = internal.to_jsonld
    @internal_changed = false
  end
  true
end

#sync_attributes!Object



36
37
38
39
40
# File 'app/models/active_annotations/annotation.rb', line 36

def sync_attributes!
  self[:uuid] = internal.annotation_id.value
  self[:source_uri] = internal.source
  true
end