shuber-eigenclass 1.0.0 → 1.0.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.
- data/CHANGELOG +2 -1
- data/README.markdown +3 -3
- data/lib/eigenclass.rb +6 -6
- data/test/eigenclass_test.rb +3 -3
- metadata +1 -1
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
|
@@ -16,9 +16,9 @@ Usage
|
|
|
16
16
|
This gem allows you to define class level accessors, readers, and writers
|
|
17
17
|
|
|
18
18
|
class SomeClass
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
eattr_accessor :test_accessor
|
|
20
|
+
eattr_reader :test_reader
|
|
21
|
+
eattr_writer :test_writer
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
SomeClass.test_accessor = 'testing'
|
data/lib/eigenclass.rb
CHANGED
|
@@ -6,11 +6,11 @@ module Huberry
|
|
|
6
6
|
# Example
|
|
7
7
|
#
|
|
8
8
|
# class User
|
|
9
|
-
#
|
|
9
|
+
# eattr_accessor :testing
|
|
10
10
|
# end
|
|
11
11
|
#
|
|
12
12
|
# User.testing = true
|
|
13
|
-
def
|
|
13
|
+
def eattr_accessor(*attrs)
|
|
14
14
|
eigenclass_eval { attr_accessor *attrs }
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -20,12 +20,12 @@ module Huberry
|
|
|
20
20
|
# Example
|
|
21
21
|
#
|
|
22
22
|
# class User
|
|
23
|
-
#
|
|
23
|
+
# eattr_reader :testing
|
|
24
24
|
# @testing = true
|
|
25
25
|
# end
|
|
26
26
|
#
|
|
27
27
|
# User.testing # returns true
|
|
28
|
-
def
|
|
28
|
+
def eattr_reader(*attrs)
|
|
29
29
|
eigenclass_eval { attr_reader *attrs }
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -35,11 +35,11 @@ module Huberry
|
|
|
35
35
|
# Example
|
|
36
36
|
#
|
|
37
37
|
# class User
|
|
38
|
-
#
|
|
38
|
+
# eattr_writer :testing
|
|
39
39
|
# end
|
|
40
40
|
#
|
|
41
41
|
# User.testing = true
|
|
42
|
-
def
|
|
42
|
+
def eattr_writer(*attrs)
|
|
43
43
|
eigenclass_eval { attr_writer *attrs }
|
|
44
44
|
end
|
|
45
45
|
|
data/test/eigenclass_test.rb
CHANGED
|
@@ -62,7 +62,7 @@ class EigenclassTest < Test::Unit::TestCase
|
|
|
62
62
|
|
|
63
63
|
def test_cattr_accessor
|
|
64
64
|
assert !TestClass.respond_to?(:this_is_a_test)
|
|
65
|
-
TestClass.
|
|
65
|
+
TestClass.eattr_accessor :this_is_a_test
|
|
66
66
|
assert TestClass.respond_to?(:this_is_a_test)
|
|
67
67
|
assert TestClass.this_is_a_test.nil?
|
|
68
68
|
TestClass.this_is_a_test = true
|
|
@@ -71,7 +71,7 @@ class EigenclassTest < Test::Unit::TestCase
|
|
|
71
71
|
|
|
72
72
|
def test_cattr_reader
|
|
73
73
|
assert !TestClass.respond_to?(:this_is_another_test)
|
|
74
|
-
TestClass.
|
|
74
|
+
TestClass.eattr_reader :this_is_another_test
|
|
75
75
|
assert TestClass.respond_to?(:this_is_another_test)
|
|
76
76
|
assert TestClass.this_is_another_test.nil?
|
|
77
77
|
TestClass.instance_variable_set('@this_is_another_test', true)
|
|
@@ -80,7 +80,7 @@ class EigenclassTest < Test::Unit::TestCase
|
|
|
80
80
|
|
|
81
81
|
def test_cattr_writer
|
|
82
82
|
assert !TestClass.respond_to?(:this_is_yet_another_test=)
|
|
83
|
-
TestClass.
|
|
83
|
+
TestClass.eattr_writer :this_is_yet_another_test
|
|
84
84
|
assert TestClass.respond_to?(:this_is_yet_another_test=)
|
|
85
85
|
assert TestClass.instance_variable_get('@this_is_yet_another_test').nil?
|
|
86
86
|
TestClass.this_is_yet_another_test = true
|