restpack_serializer 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3653897a848f7ef9177a0a3598c36ff1a92e6e17
4
- data.tar.gz: b8bf0041bff0b00b97e57aeef99418a08e2b708d
3
+ metadata.gz: 8306de0e143806588fef98d814a5192f60f65ae0
4
+ data.tar.gz: c398f21e59a7f5b05132a3f9b7910d58373493e1
5
5
  SHA512:
6
- metadata.gz: 0e1ab45909bcc27861471bea9eae1cde81b82a6636f4e7d65f06cd836ff13338a3f16fc2ba6942c902921df66159657d281778f0a1c26d5885fa2c0267c34b14
7
- data.tar.gz: 4ef98b446cefd687a2ee157c619706302dcb156bf3b194a9ba590e87d6b5a46411b04042eb21a572d46782413c889aa1e8f78e5f0d8ca7d53ca19252b47ffa42
6
+ metadata.gz: 226bf5411139df7703abb7c32d90e9d07f6537b823bdb18792ea38cd449b80d6c29e5ffd11bed89e1939241211a63d8ab6244e310d469e031e1b75385dc7a7a7
7
+ data.tar.gz: 327070d269ca743f15d2217cce4e3a9c5b013ae39bf8a3e13eb0f2f9eff398bc142cdc62e8c405a615b92fb1b714a87ab313f97b03c5f57cdb197a23a3cdfae2
@@ -112,6 +112,13 @@ module RestPack
112
112
  (@key || self.model_class.send(:table_name)).to_sym
113
113
  end
114
114
 
115
+ def singular_key
116
+ self.key.to_s.singularize.to_sym
117
+ end
118
+
119
+ def plural_key
120
+ self.key
121
+ end
115
122
  end
116
123
  end
117
124
  end
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Serializer
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
  end
5
5
  end
@@ -190,18 +190,32 @@ describe RestPack::Serializer do
190
190
  end
191
191
 
192
192
  describe "#key" do
193
- it "returns the correct key" do
194
- PersonSerializer.key.should == :people
193
+ context "with default key" do
194
+ it "returns the correct key" do
195
+ PersonSerializer.key.should == :people
196
+ end
197
+
198
+ it "has correct #singular_key" do
199
+ PersonSerializer.singular_key.should == :person
200
+ end
201
+
202
+ it "has correct #plural_key" do
203
+ PersonSerializer.plural_key.should == :people
204
+ end
195
205
  end
196
206
 
197
207
  context "with custom key" do
198
208
  class SerializerWithCustomKey
199
209
  include RestPack::Serializer
200
- self.key = :custom_key
210
+ self.key = :customers
201
211
  end
202
212
 
203
213
  it "returns the correct key" do
204
- SerializerWithCustomKey.key.should == :custom_key
214
+ SerializerWithCustomKey.key.should == :customers
215
+ end
216
+
217
+ it "has correct #singular_key" do
218
+ SerializerWithCustomKey.singular_key.should == :customer
205
219
  end
206
220
  end
207
221
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Joyce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-09 00:00:00.000000000 Z
11
+ date: 2014-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport