rapidash 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rapidash/resourceable.rb +8 -4
- data/lib/rapidash/version.rb +1 -1
- data/spec/rapidash/resourceable_spec.rb +30 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0efe6c53b4dda6119666b7b280aa8ab1315640a
|
4
|
+
data.tar.gz: 229e2f7d0836fc06ae2f8656d23fe30e7713f0b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7efc8162ed268a6512bcaf02fb3529a2df0a0ab3f17448740aefa98454023f56ae73f63475fbf81c37daa0efb74c9b290c77afe6e4bf183c1ca7994a5e465c4c
|
7
|
+
data.tar.gz: 332545525ee072dc890f708eb58ef9b251759d05bc41e8e485e7184258044b6cbf1423425b63cb51391e5e0971018cb0f4f38e40ead5aa32d78417ec33047d19
|
@@ -24,20 +24,24 @@ module Rapidash
|
|
24
24
|
options = names.extract_options!
|
25
25
|
|
26
26
|
mod = self.to_s.split("::")[0...-1]
|
27
|
-
mod = mod.empty? ? Object :
|
27
|
+
mod = mod.empty? ? Object : mod.join("::").constantize
|
28
28
|
|
29
29
|
names.each do |name|
|
30
30
|
if options[:class_name]
|
31
|
-
class_name = options[:class_name]
|
31
|
+
class_name = options[:class_name].to_s
|
32
32
|
else
|
33
33
|
class_name = name.to_s.camelcase.singularize
|
34
|
+
|
35
|
+
unless mod == Object
|
36
|
+
class_name = "#{mod}::#{class_name}"
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
begin
|
37
|
-
klass =
|
41
|
+
klass = class_name.constantize
|
38
42
|
rescue NameError
|
39
43
|
Kernel.warn "[DEPRECATED] - RAPIDASH WARNING using #{class_name.pluralize} instead of #{class_name.singularize} - please either use `#{class_name.singularize}` or set the class name with `resource #{name}, :class_name => #{class_name.pluralize}` implicit plural naming will be deprecated in Rapidash 1.0"
|
40
|
-
klass =
|
44
|
+
klass = class_name.pluralize.constantize
|
41
45
|
end
|
42
46
|
|
43
47
|
define_method(name) do |*args|
|
data/lib/rapidash/version.rb
CHANGED
@@ -120,7 +120,7 @@ describe Rapidash::Resourceable do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should not fail when presented with a multi-word resource" do
|
123
|
-
expect {
|
123
|
+
expect {
|
124
124
|
class ClientTester
|
125
125
|
resource :admin_users
|
126
126
|
end
|
@@ -205,9 +205,14 @@ describe Rapidash::Resourceable do
|
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
|
-
module
|
209
|
-
module
|
210
|
-
class
|
208
|
+
module SomeModule
|
209
|
+
module SomeSubModule
|
210
|
+
class User
|
211
|
+
def initialize(*args)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
class Post
|
211
216
|
def initialize(*args)
|
212
217
|
end
|
213
218
|
end
|
@@ -218,7 +223,8 @@ describe Rapidash::Resourceable do
|
|
218
223
|
include Rapidash::Resourceable
|
219
224
|
resource :users, :class_name => "Facebook::User"
|
220
225
|
resource :posts, :class_name => Facebook::Posts
|
221
|
-
resource :
|
226
|
+
resource :deep_users, :class_name => "SomeModule::SomeSubModule::User"
|
227
|
+
resource :deep_posts, :class_name => SomeModule::SomeSubModule::Post
|
222
228
|
end
|
223
229
|
|
224
230
|
it "should find user in another module" do
|
@@ -229,8 +235,25 @@ describe Rapidash::Resourceable do
|
|
229
235
|
ModuleTester.new.posts.class.should eql(Facebook::Posts)
|
230
236
|
end
|
231
237
|
|
232
|
-
it "should find
|
233
|
-
ModuleTester.new.
|
238
|
+
it "should find deep_users in a nested module" do
|
239
|
+
ModuleTester.new.deep_users.class.should eql(SomeModule::SomeSubModule::User)
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should find deep_posts in a nested class name" do
|
243
|
+
ModuleTester.new.deep_posts.class.should eql(SomeModule::SomeSubModule::Post)
|
234
244
|
end
|
245
|
+
|
246
|
+
it "should not raise a wrong constant NameError" do
|
247
|
+
expect {
|
248
|
+
module Deep
|
249
|
+
module ModuleTester
|
250
|
+
class MyResource < Rapidash::Base
|
251
|
+
resource :users, :class_name => "Facebook::User"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
}.to_not raise_error(NameError)
|
256
|
+
end
|
257
|
+
|
235
258
|
end
|
236
259
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapidash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary 'Gazler' Rennie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|