# Code coverage report for lib/template/view/reference.js

## Statements: 100% (13 / 13) Branches: 100% (6 / 6) Functions: 100% (3 / 3) Lines: 100% (12 / 12) Ignored: none

All files » lib/template/view/ » reference.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    421

    1
    32
    32
    32
    32

    1

    27
    16

    11

    3

    1
     var protoclass = require("protoclass");

    /**
     */

    function Reference(view, path, settable, gettable) {
      this.view     = view;
      this.path     = path;
      this.settable = settable !== false;
      this.gettable = gettable !== false;
    }

    /**
     */

    protoclass(Reference, {

      /**
       */

      __isReference: true,

      /**
       */

      value: function(value) {
        if (!arguments.length) {
          return this.gettable ? this.view.get(this.path) : void 0;
        }
        if (this.settable) this.view.set(this.path, value);
      },

      /**
       */

      toString: function() {
        return this.view.get(this.path);
      }
    });

    module.exports = Reference;