src/records/Fact.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 41
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 41
rs 10
wmc 5
mnd 1
bc 5
fnc 4
bpm 1.25
cpm 1.25
noi 0
1
/**
2
 * Record extensions to Fact
3
 */
4
module.exports = function(GedcomX){
5
  
6
  // Extend serialization properties
7
  GedcomX.Fact.jsonProps.push('primary');
8
  
9
  // Override init()
10
  var oldFactInit = GedcomX.Fact.prototype.init;
11
  GedcomX.Fact.prototype.init = function(json){
12
    oldFactInit.call(this, json);
13
    if(json){
14
      this.setPrimary(json.primary);
15
    }
16
  };
17
  
18
  /**
19
   * Set the primary flag
20
   * 
21
   * @function setPrimary
22
   * @instance
23
   * @memberof Fact
24
   * @param {Boolean} primary
25
   * @return {Fact} this
26
   */
27
  GedcomX.Fact.prototype.setPrimary = function(primary){
28
    this.primary = primary;
29
    return this;
30
  };
31
  
32
  /**
33
   * Get the primary flag
34
   * 
35
   * @function getPrimary
36
   * @instance
37
   * @memberof Fact
38
   * @return {Boolean}
39
   */
40
  GedcomX.Fact.prototype.getPrimary = function(){
41
    return this.primary;
42
  };
43
  
44
};