Skip to content

Instantly share code, notes, and snippets.

@blackjid
Created October 6, 2015 23:39
Show Gist options
  • Select an option

  • Save blackjid/d1eb60243a62e35c1725 to your computer and use it in GitHub Desktop.

Select an option

Save blackjid/d1eb60243a62e35c1725 to your computer and use it in GitHub Desktop.

Revisions

  1. blackjid created this gist Oct 6, 2015.
    20 changes: 20 additions & 0 deletions noroot-ams.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    angular.module('restmod').factory('RootlessAMSApi', ['restmod', 'inflector', function(restmod, inflector) {

    return restmod.mixin({ // include default packer extension
    $config: {
    style: 'AMS',
    primaryKey: 'id',
    jsonMeta: 'meta',
    jsonLinks: 'links'
    },

    $extend: {
    // special snakecase to camelcase renaming
    Model: {
    decodeName: inflector.camelize,
    encodeName: function(_v) { return inflector.parameterize(_v, '_'); }
    }
    }
    });

    }]);