attr-utils 0.1.1 → 0.2.0
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/README.md +1 -1
- data/lib/attr-utils.rb +2 -2
- data/lib/attr-utils/attr_list.rb +18 -3
- data/lib/attr-utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a06305342dd4815e55b6d704ac50df09c5d3bc7bbe6981518ca32f674a198b60
|
4
|
+
data.tar.gz: 0b6bca03e59e82c8f5c916101bc3944d2c171350d999a39164758caabf87b75b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77c71494c3230b861bd1e758d976e3df4626685184e4f73d6600b4a10d336742e014a4beff100309f55cd18866dc6adddcc64edf2da4e40562e860a1585a9baa
|
7
|
+
data.tar.gz: 2344839c11e20d4b5d7f4edf936956f8444a27d7695bc00beb9267a8be328ec59021de2457608ea6a6d765bb0916803f238d0a5efea83c0d4f521710f45234c6
|
data/README.md
CHANGED
data/lib/attr-utils.rb
CHANGED
data/lib/attr-utils/attr_list.rb
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
module AttrUtils
|
2
2
|
module AttrList
|
3
|
-
|
3
|
+
def self.included(mod)
|
4
|
+
mod.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
# Return attributes' name which has getter and setter methods in the class.
|
9
|
+
# Hopefully they may identical with attributes defined as "attr_accessor".
|
10
|
+
#
|
11
|
+
# @return [Array<Symbol>]
|
12
|
+
def list_attr_accessors
|
13
|
+
my_methods = instance_methods - %w(== === !=).map(&:to_sym)
|
14
|
+
my_methods.select{|m| my_methods.find{|m2| "#{m.to_s}=" == m2.to_s } }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return attributes' name which has getter and setter methods in the instannce.
|
4
19
|
# Hopefully they may identical with attributes defined as "attr_accessor".
|
5
20
|
#
|
6
21
|
# @return [Array<Symbol>]
|
7
22
|
def list_attr_accessors
|
8
|
-
|
9
|
-
|
23
|
+
my_methods = methods - %w(== === !=).map(&:to_sym)
|
24
|
+
my_methods.select{|m| my_methods.find{|m2| "#{m.to_s}=" == m2.to_s } }
|
10
25
|
end
|
11
26
|
end
|
12
27
|
end
|
data/lib/attr-utils/version.rb
CHANGED