resterl 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/resterl/class_level_inheritable_attributes.rb +4 -4
- data/resterl.gemspec +1 -1
- data/test/test_resterl.rb +17 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -7,18 +7,18 @@ module ClassLevelInheritableAttributes
|
|
7
7
|
|
8
8
|
module ClassMethods
|
9
9
|
def inheritable_attributes(*args)
|
10
|
-
@
|
11
|
-
@
|
10
|
+
@resterl_inheritable_attributes ||= [:inheritable_attributes]
|
11
|
+
@resterl_inheritable_attributes += args
|
12
12
|
args.each do |arg|
|
13
13
|
class_eval %(
|
14
14
|
class << self; attr_accessor :#{arg} end
|
15
15
|
)
|
16
16
|
end
|
17
|
-
@
|
17
|
+
@resterl_inheritable_attributes
|
18
18
|
end
|
19
19
|
|
20
20
|
def inherited(subclass)
|
21
|
-
@
|
21
|
+
@resterl_inheritable_attributes.each do |inheritable_attribute|
|
22
22
|
instance_var = "@#{inheritable_attribute}"
|
23
23
|
subclass.instance_variable_set(instance_var,
|
24
24
|
instance_variable_get(instance_var))
|
data/resterl.gemspec
CHANGED
data/test/test_resterl.rb
CHANGED
@@ -16,4 +16,21 @@ class TestResterl < Test::Unit::TestCase
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
|
+
context 'BaseObject' do
|
20
|
+
should 'provide class level inheritable attributes' do
|
21
|
+
|
22
|
+
assert_nil Resterl::BaseObject.resterl_client
|
23
|
+
assert_nil Resterl::BaseObject.complete_mime_type
|
24
|
+
|
25
|
+
assert_nothing_raised do
|
26
|
+
class Test < Resterl::BaseObject
|
27
|
+
self.resterl_client = nil
|
28
|
+
self.complete_mime_type = 'text/plain'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
19
36
|
end
|