attr-utils 0.1.1 → 0.2.0

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
  SHA256:
3
- metadata.gz: 2dfcdf7d3332466c264e7b904093e2aa671d9ac851011380e640deafb6a24676
4
- data.tar.gz: bbd619d4a9e90f7f224393184e2e976378b6144216eea8962acc19aa6b85531b
3
+ metadata.gz: a06305342dd4815e55b6d704ac50df09c5d3bc7bbe6981518ca32f674a198b60
4
+ data.tar.gz: 0b6bca03e59e82c8f5c916101bc3944d2c171350d999a39164758caabf87b75b
5
5
  SHA512:
6
- metadata.gz: 0d31da796d6cbc939dbbb5fb210add6baeb031edd1c9cf684574ef77fb06726293b7ec56621cfe74f85cb469e45d679de9e1ba176d3533b51120449f8e9e0ee4
7
- data.tar.gz: 20cd1e9a37f0acd48e5174e3c871895233605e512b66857d1e84455c5d1693d3ed429f1dc9d7566fb8fac1b7a560a15cfd301df38553ff16a31beb751e7b7a38
6
+ metadata.gz: 77c71494c3230b861bd1e758d976e3df4626685184e4f73d6600b4a10d336742e014a4beff100309f55cd18866dc6adddcc64edf2da4e40562e860a1585a9baa
7
+ data.tar.gz: 2344839c11e20d4b5d7f4edf936956f8444a27d7695bc00beb9267a8be328ec59021de2457608ea6a6d765bb0916803f238d0a5efea83c0d4f521710f45234c6
data/README.md CHANGED
@@ -8,6 +8,6 @@ Just require and extend AttrUtils whereever you want.
8
8
  require 'attr-utils'
9
9
 
10
10
  class Test
11
- extend AttrUtils
11
+ include AttrUtils
12
12
  end
13
13
  ```
@@ -1,8 +1,8 @@
1
1
  $LOAD_PATH << File.join(File.dirname(__FILE__), '../lib')
2
2
 
3
3
  module AttrUtils
4
- def self.extended(mod)
5
- mod.extend AttrUtils::AttrList
4
+ def self.included(mod)
5
+ mod.include AttrUtils::AttrList
6
6
  end
7
7
  end
8
8
 
@@ -1,12 +1,27 @@
1
1
  module AttrUtils
2
2
  module AttrList
3
- # Return attributes' name which has getter and setter methods in the class.
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
- methods = instance_methods - %w(== === !=).map(&:to_sym)
9
- methods.select{|m| methods.find{|m2| "#{m.to_s}=" == m2.to_s } }
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
@@ -1,4 +1,4 @@
1
1
  module AttrUtils
2
- Version = '0.1.1'
2
+ Version = '0.2.0'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Morimoto