enum_args 1.1.2 → 1.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 +3 -2
- data/lib/enum_args/proxied_enumerable.rb +13 -0
- data/lib/enum_args/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2913b0335572c780c47b1a60a07c29e7ff7fd56
|
4
|
+
data.tar.gz: 1c7e946a38c9bd717963be25ede30ad5aaab1a16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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)
|
data/lib/enum_args/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|