attire 0.1.0 → 0.1.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 +4 -4
- data/lib/attire/attr_init.rb +1 -1
- data/lib/attire/initializer.rb +13 -11
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c396ea5af36aa2c91ef57a595a1bd5932960e3
|
4
|
+
data.tar.gz: e344b21c4a14beca79f37b226d6c55dcb97dcd9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0be6c4e1eeaf27283c92a7b73f8ce949ae5c6ee1134c2cc7ae50e52a52830d75a01a96206ea5ccad19b4dce93e716a82c96f50b91c28d776abf25bec9ae22f9
|
7
|
+
data.tar.gz: b84369c42d537c55b79d2585461e57007ae736dff4fd71926a0ee64db0b7543f05bbc82c26889af9437fe4633dd74919bd64b1c95a7a9e8dc9c94758307efac1
|
data/lib/attire.rb
CHANGED
@@ -9,13 +9,13 @@ module Attire
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def attr_init(*names, &
|
13
|
-
AttrInit.apply(self, names,
|
12
|
+
def attr_init(*names, &block)
|
13
|
+
AttrInit.apply(self, names, block)
|
14
14
|
end
|
15
15
|
|
16
|
-
def attr_method(verb, *names, &
|
16
|
+
def attr_method(verb, *names, &block)
|
17
17
|
define_singleton_method(verb) { |*a, &b| new(*a, &b).send(verb) }
|
18
|
-
attr_init(*names, &
|
18
|
+
attr_init(*names, &block)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/lib/attire/attr_init.rb
CHANGED
@@ -68,7 +68,7 @@ module Attire
|
|
68
68
|
|
69
69
|
def excess_splat_and_block_names_check
|
70
70
|
return if names.none? { |n| n.to_s.start_with?('&', '*') }
|
71
|
-
fail ArgumentError,
|
71
|
+
fail ArgumentError, 'Splat and Block arguments must be last'
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
data/lib/attire/initializer.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Attire
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class Initializer
|
3
|
+
def initialize(names, splat_name, block_name, after_initialize)
|
4
|
+
@names = names
|
5
|
+
@splat_name = splat_name
|
6
|
+
@block_name = block_name
|
7
|
+
@after_initialize = after_initialize
|
8
|
+
end
|
9
9
|
|
10
|
-
|
10
|
+
def instance_initialize(instance, values, value_block)
|
11
11
|
@instance, @values, @value_block = instance, values, value_block
|
12
12
|
arity_check
|
13
13
|
set_ivars
|
@@ -17,7 +17,7 @@ module Attire
|
|
17
17
|
private
|
18
18
|
|
19
19
|
attr_reader :names, :splat_name, :block_name, :after_initialize,
|
20
|
-
|
20
|
+
:instance, :values, :value_block
|
21
21
|
|
22
22
|
def set_ivars
|
23
23
|
names.zip(values).each do |name, value|
|
@@ -30,7 +30,9 @@ module Attire
|
|
30
30
|
def set_hash(defaults, values)
|
31
31
|
values ||= {}
|
32
32
|
hash_check(values)
|
33
|
-
defaults.each
|
33
|
+
defaults.each do |name, default|
|
34
|
+
set_ivar(name, values[name].nil? ? default : values[name])
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
def set_splat
|
@@ -68,5 +70,5 @@ module Attire
|
|
68
70
|
def arity_range
|
69
71
|
@arity_range ||= (min_arity..max_arity)
|
70
72
|
end
|
71
|
-
|
73
|
+
end
|
72
74
|
end
|
metadata
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.1'
|
20
|
-
- -
|
20
|
+
- - '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 3.1.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.1'
|
30
|
-
- -
|
30
|
+
- - '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.1.0
|
33
33
|
description:
|
@@ -51,17 +51,17 @@ require_paths:
|
|
51
51
|
- lib
|
52
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - '>='
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
63
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.
|
64
|
+
rubygems_version: 2.4.1
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: Convenience methods to remove some boiler plate in defining classes.
|