evt-subst_attr 0.1.0.2 → 0.2.0.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 +5 -5
- data/lib/subst_attr/attribute.rb +1 -1
- data/lib/subst_attr/controls.rb +2 -0
- data/lib/subst_attr/controls/dependency.rb +20 -0
- data/lib/subst_attr/controls/example.rb +25 -0
- data/lib/subst_attr/substitute.rb +7 -12
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c2492920559c438f81ab423c64780cab728da18ac49b6f1ecce7bd0dc217f18
|
4
|
+
data.tar.gz: bad346b34a2d4793e27b518300327fc4eb041a2a77bc14a65bd84d2981c4c40f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38090e6794ef9b7b1b9df7e85a0f8a145227b12f480b563ddca9f8acfa0cbea56e5845bd72b7dbee2ff1b934246c3db0a45667658ab5a27ce6d38b5075bdbbd0
|
7
|
+
data.tar.gz: 7953d7d8adcec6dbb03712ae13038b370cc110d054d6e298abffdfd03082a5590e84f04386fc4c43d64bf14f1748d2413ad04ace86a4cd2b3004413afc3b8e95
|
data/lib/subst_attr/attribute.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module SubstAttr
|
2
|
+
module Controls
|
3
|
+
module Dependency
|
4
|
+
class Example
|
5
|
+
def self.configure(receiver)
|
6
|
+
receiver.some_attr = new
|
7
|
+
end
|
8
|
+
|
9
|
+
module Substitute
|
10
|
+
def self.build
|
11
|
+
:some_substutute
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Descendant < Example
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module SubstAttr
|
2
|
+
module Controls
|
3
|
+
class Example
|
4
|
+
extend SubstAttr::Macro
|
5
|
+
|
6
|
+
subst_attr :some_attr, Dependency::Example
|
7
|
+
|
8
|
+
subst_attr :weak_attr
|
9
|
+
|
10
|
+
def self.build
|
11
|
+
new.tap do |instance|
|
12
|
+
Dependency::Example.configure(instance)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Ancestry
|
17
|
+
class Example
|
18
|
+
extend SubstAttr::Macro
|
19
|
+
|
20
|
+
subst_attr :some_attr, Dependency::Example::Descendant
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -4,11 +4,11 @@ module SubstAttr
|
|
4
4
|
|
5
5
|
def build(interface=nil)
|
6
6
|
if interface
|
7
|
-
specialization = specialization(interface
|
7
|
+
specialization = specialization(interface)
|
8
8
|
return specialization if specialization
|
9
9
|
end
|
10
10
|
|
11
|
-
return NullObject.build
|
11
|
+
return NullObject.build(interface)
|
12
12
|
end
|
13
13
|
|
14
14
|
def call(attr_name, receiver)
|
@@ -17,7 +17,8 @@ module SubstAttr
|
|
17
17
|
receiver.send :"#{attr_name}=", substitute
|
18
18
|
end
|
19
19
|
|
20
|
-
def specialization(interface
|
20
|
+
def specialization(interface)
|
21
|
+
const_name = :Substitute
|
21
22
|
unless interface.const_defined?(const_name)
|
22
23
|
return nil
|
23
24
|
end
|
@@ -28,7 +29,7 @@ module SubstAttr
|
|
28
29
|
return nil
|
29
30
|
end
|
30
31
|
|
31
|
-
mod.send
|
32
|
+
mod.send(:build)
|
32
33
|
end
|
33
34
|
|
34
35
|
module NullObject
|
@@ -43,13 +44,7 @@ module SubstAttr
|
|
43
44
|
|
44
45
|
def build(interface=nil)
|
45
46
|
if interface
|
46
|
-
|
47
|
-
|
48
|
-
if specialization
|
49
|
-
return specialization
|
50
|
-
else
|
51
|
-
return strict interface
|
52
|
-
end
|
47
|
+
return strict(interface)
|
53
48
|
end
|
54
49
|
|
55
50
|
weak
|
@@ -62,7 +57,7 @@ module SubstAttr
|
|
62
57
|
def strict(interface)
|
63
58
|
Naught.build do |config|
|
64
59
|
config.singleton
|
65
|
-
config.impersonate
|
60
|
+
config.impersonate(interface)
|
66
61
|
end.get
|
67
62
|
end
|
68
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-subst_attr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-attribute
|
@@ -61,6 +61,9 @@ files:
|
|
61
61
|
- lib/subst_attr.rb
|
62
62
|
- lib/subst_attr/activate.rb
|
63
63
|
- lib/subst_attr/attribute.rb
|
64
|
+
- lib/subst_attr/controls.rb
|
65
|
+
- lib/subst_attr/controls/dependency.rb
|
66
|
+
- lib/subst_attr/controls/example.rb
|
64
67
|
- lib/subst_attr/macro.rb
|
65
68
|
- lib/subst_attr/substitute.rb
|
66
69
|
homepage: https://github.com/eventide-project/subst-attr
|
@@ -83,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
86
|
version: '0'
|
84
87
|
requirements: []
|
85
88
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.7.3
|
87
90
|
signing_key:
|
88
91
|
specification_version: 4
|
89
92
|
summary: Declare attributes that have default implementations that are substitutes
|