enum_args 1.1.2 → 1.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
  SHA1:
3
- metadata.gz: 68df5fb718558589a21017b5855a79dbf5ac7a7d
4
- data.tar.gz: eca79a772cb5d8e2acd15e3043d10bb3329ac371
3
+ metadata.gz: e2913b0335572c780c47b1a60a07c29e7ff7fd56
4
+ data.tar.gz: 1c7e946a38c9bd717963be25ede30ad5aaab1a16
5
5
  SHA512:
6
- metadata.gz: ed587f106c77f0c9d4d1c05ded01163f8ab4f460d970c3cf2e32d112d1d78d0fddb8909b504927ca1e9f74be09316efeb55cb0b7fd856a413f3f66b02b577cf5
7
- data.tar.gz: f2169665ffff932f9b15d0361b394f8298208568feb35fb0b6d97b4dc1670ebeaedfe3216b539ab1d6c299be0518ac2759c73b97be6adc9324895914b1dd84fc
6
+ metadata.gz: 38afacece71ca7fda1e7c3dbf41a8ba2c1b977a3bf761cfc3e62e90e7d77b1b3c157effb07ca3704ea49ca6789c2b56a7607912dc4c7fc477722b88a96429713
7
+ data.tar.gz: 6530213646faaeeb20fbea43eb0f7f3413fda45043bd3ebb326bf3a30d0eb302414db5e028c0044e62851d2e5eade34c634437a7c6e07f02ebb5a17e49ecc8a1
data/README.md CHANGED
@@ -41,11 +41,12 @@ EnumArgs adds all the Enumerable instance methods and a corresponding `each`
41
41
  method, which is what we need for a collection, and other than that, just _one_
42
42
  single accessor (instance) method to your class and _one_ single instance variable
43
43
  with configurable name (default is `enum_args`). You can specify what that name
44
- should look like by specifying the `with_enum_args_as: :method_name` option to
44
+ should look like by adding the `with_enum_args_as: :method_name` option to
45
45
  `enum_args_for`.
46
46
 
47
47
  A few _class_ methods are added as well to hold default values for your
48
- enumerator, all of them prefixed with `enum_args_`.
48
+ enumerator, all of them prefixed with `enum_args_`, and an `inherited` hook is
49
+ prepended to support inheritcance.
49
50
 
50
51
  ## Installation
51
52
 
@@ -5,6 +5,9 @@ module EnumArgs
5
5
 
6
6
  module ProxiedEnumerable
7
7
  module ClassMethods
8
+ METHODS = [:enum_args_method, :enum_args_accessor_method,
9
+ :enum_args_default_args, :enum_args_default_using]
10
+
8
11
  def enum_args_method
9
12
  @enum_args_method ||= :iterator
10
13
  end
@@ -28,6 +31,16 @@ module EnumArgs
28
31
  @enum_args_default_using = using
29
32
  @enum_args_accessor_method = with_enum_args_as
30
33
  end
34
+
35
+ me = self # bound variable for the :inherited block
36
+
37
+ define_method :inherited do |klass|
38
+ klass.singleton_class.prepend me
39
+ METHODS.each do |m|
40
+ klass.instance_variable_set("@#{m}", send(m))
41
+ end
42
+ super(klass)
43
+ end
31
44
  end
32
45
 
33
46
  def self.prepended(base)
@@ -1,3 +1,3 @@
1
1
  module EnumArgs
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enum_args
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Martinez Ruiz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler