attire 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/attire.rb +25 -21
- 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: 846310cee11e1fedbc86238e416787070404a122
|
4
|
+
data.tar.gz: 2b62ef8468309877f57edd7cfef43ec6a22f7652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbfce629ad166304f68f845dbcaf3a8a19c889023c305c1cba87aeb653c92577bba7d25e755d9286b2131045d7c8d11a89f38a00616ce1fd0622d39d13f9321b
|
7
|
+
data.tar.gz: c7a3f0d225cba83bac4d5492b6ad46fd5e7dbb7b35f8191c57d18d174bbf18b22e7e8fe060dbd94b61be2a279563c2e9f7b87c73c1223e59256e852de340b56e
|
data/lib/attire.rb
CHANGED
@@ -1,32 +1,36 @@
|
|
1
1
|
module Attire
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class << self
|
3
|
+
def attire(base, param_str, method: :initialize, verb: nil, &after)
|
4
|
+
names = eval("->(#{param_str}){}").parameters.map(&:last)
|
5
|
+
def_init(base, param_str, method, names)
|
6
|
+
add_getters(base, names)
|
7
|
+
base.send(:define_method, :__after) { instance_exec(&after) if after }
|
8
|
+
def_verb(base, verb) if verb
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
+
private
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def def_init(base, param_str, method, names)
|
14
|
+
base.class_eval "def #{method}(#{param_str})\n#{ivars(names)}\n__after\nend"
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def ivars(names)
|
18
|
+
names.map { |name| "@#{name} = #{name}\n" }.join
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def add_getters(base, names)
|
22
|
+
base.send(:attr_reader, *names)
|
23
|
+
base.send(:private, *names)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
def def_verb(base, verb)
|
27
|
+
base.define_singleton_method(verb) { |*a, &b| new(*a, &b).send(verb) }
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
class Module
|
31
|
-
|
33
|
+
def attire(*a, &b)
|
34
|
+
Attire.attire(self, *a, &b)
|
35
|
+
end
|
32
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|