Completed
Push — master ( e3ee1d...5cbb1b )
by Justin
01:36
created

src/rs/ResourceReference.js   A

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 35
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 35
rs 10
wmc 5
mnd 1
bc 5
fnc 4
bpm 1.25
cpm 1.25
noi 0
1
/**
2
 * RS extensions to ResourceReference
3
 */
4
module.exports = function(GedcomX){
5
  
6
  // Extend serialization properties
7
  GedcomX.ResourceReference.jsonProps.push('resourceId');
8
  
9
  // Override init() so that we can deserialize normalized values
10
  var oldInit = GedcomX.ResourceReference.prototype.init;
11
  GedcomX.ResourceReference.prototype.init = function(json){
12
    oldInit.call(this, json);
13
    if(json){
14
      this.setResourceId(json.resourceId);
15
    }
16
  };
17
  
18
  /**
19
   * Set the resourceId
20
   * 
21
   * @param {Boolean} resourceId
22
   * @return {ResourceReference} this
23
   */
24
  GedcomX.ResourceReference.prototype.setResourceId = function(resourceId){
25
    this.resourceId = resourceId;
26
    return this;
27
  };
28
  
29
  /**
30
   * Get the resourceId
31
   * 
32
   * @return {Boolean} resourceId
33
   */
34
  GedcomX.ResourceReference.prototype.getResourceId = function(){
35
    return this.resourceId;
36
  };
37
  
38
};