Skip to content

Commit ddad7e4

Browse files
committed
fix(DefaultPacker): fixes plural name not being infered from name.
Fixes #224
1 parent d2f0c0c commit ddad7e4

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/module/support/default-packer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', func
9898
meta = this.getProperty('jsonMeta', 'meta');
9999

100100
if(_resource.$isCollection) {
101-
name = this.getProperty('jsonRootMany') || this.getProperty('jsonRoot') || this.getProperty('plural');
101+
name = this.getProperty('jsonRootMany') || this.getProperty('jsonRoot') || this.identity(true);
102102
} else {
103103
// TODO: use plural for single resource option.
104-
name = this.getProperty('jsonRootSingle') || this.getProperty('jsonRoot') || this.getProperty('name');
104+
name = this.getProperty('jsonRootSingle') || this.getProperty('jsonRoot') || this.identity();
105105
}
106106

107107
if(meta) {

test/default-packer-spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ describe('DefaultPacker', function() {
2424
});
2525

2626
it('should extract collection using plural name by default', function() {
27-
var model = restmod.model('/api/bikes').mix('DefaultPacker');
27+
var model = restmod.model().mix({
28+
$config: { name: 'bike' }
29+
}).mix('DefaultPacker');
2830

2931
var many = model.$collection();
3032
many.$unwrap({ bikes: [{ model: 'Slash' }] });

0 commit comments

Comments
 (0)