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

## Statements: 91.67% (11 / 12) Branches: 100% (4 / 4) Functions: 66.67% (2 / 3) Lines: 90% (9 / 10) 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
    401

    1
    12
    12
    12

    1

    12
    5

    1
     var protoclass = require("protoclass");

    /**
     */

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

    /**
     */

    protoclass(Reference, {

      /**
       */

      __isReference: true,

      /**
       */

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

      /**
       */

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

    module.exports = Reference;