Class: CaTissue::Annotation::Integrator

Inherits:
Object
  • Object
show all
Defined in:
lib/catissue/database/annotation/integrator.rb

Overview

An Integrator fetches and saves CaTissue hook-annotation associations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mod) ⇒ Integrator

Returns a new instance of Integrator.

Parameters:

  • the (Module)

    annotation module



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/catissue/database/annotation/integrator.rb', line 10

def initialize(mod)
  re_cls = mod.record_entry_class
  # the integration delegate
  @dlg = if re_cls then
    require 'catissue/database/annotation/record_entry_integrator'
    @order = :prefix
    RecordEntryIntegrator.new(mod)
  else
    require 'catissue/database/annotation/integration_service'
    @order = :postfix
    IntegrationService.new
  end
end

Instance Attribute Details

#order:prefix, :postfix (readonly)

Returns whether integration is performed before or after the annotation save.

Returns:

  • (:prefix, :postfix)

    whether integration is performed before or after the annotation save



7
8
9
# File 'lib/catissue/database/annotation/integrator.rb', line 7

def order
  @order
end

Instance Method Details

#associate(hook, annotation) ⇒ Object

Associates the given hook domain object to the annotation.

Parameters:



28
29
30
31
32
33
34
35
# File 'lib/catissue/database/annotation/integrator.rb', line 28

def associate(hook, annotation)
  logger.debug { "Associating annotation #{annotation} to owner #{hook}..." }
  # the hook must have an identifier
  if hook.identifier.nil? then
    raise CaRuby::DatabaseError.new("Static hook object #{hook} referenced by annotation #{annotation} does not have an identifier")
  end
  @dlg.associate(hook, annotation)
end