Class: ActiveFacts::CQL::Compiler::ContextNote

Inherits:
Object
  • Object
show all
Defined in:
lib/activefacts/cql/compiler/constraint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context_kind, discussion, who, agreed) ⇒ ContextNote

Returns a new instance of ContextNote.



19
20
21
22
# File 'lib/activefacts/cql/compiler/constraint.rb', line 19

def initialize context_kind, discussion, who, agreed
  @context_kind, @discussion, @who, @agreed = context_kind, discussion, who, agreed
  @agreed_date, @agreed_agents = *agreed
end

Instance Attribute Details

#agreed_agentsObject (readonly)

Returns the value of attribute agreed_agents.



17
18
19
# File 'lib/activefacts/cql/compiler/constraint.rb', line 17

def agreed_agents
  @agreed_agents
end

#agreed_dateObject (readonly)

Returns the value of attribute agreed_date.



17
18
19
# File 'lib/activefacts/cql/compiler/constraint.rb', line 17

def agreed_date
  @agreed_date
end

#context_kindObject (readonly)

Returns the value of attribute context_kind.



17
18
19
# File 'lib/activefacts/cql/compiler/constraint.rb', line 17

def context_kind
  @context_kind
end

#discussionObject (readonly)

Returns the value of attribute discussion.



17
18
19
# File 'lib/activefacts/cql/compiler/constraint.rb', line 17

def discussion
  @discussion
end

#whoObject (readonly)

Returns the value of attribute who.



17
18
19
# File 'lib/activefacts/cql/compiler/constraint.rb', line 17

def who
  @who
end

Instance Method Details

#compile(constellation, target) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/activefacts/cql/compiler/constraint.rb', line 24

def compile constellation, target
  context_note =
    constellation.ContextNote(
      :new,
      :context_note_kind => @context_kind,
      :discussion => @discussion
    )
  context_note.relevant_concept = target.concept
  if @agreed_date || @agreed_agents
    agreement = constellation.Agreement(context_note)
    agreement.date = @agreed_date if @agreed_date
    @agreed_agents.each do |agent|
      constellation.ContextAgreedBy(agreement, agent)
    end
  end
  if @who && @who.size > 0
    @who.each do |agent|
      constellation.ContextAccordingTo(context_note, agent)
    end
  end
  context_note
end