angostura 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/angostura/dependencies.rb +32 -0
- data/lib/angostura/dependency_error.rb +5 -0
- data/lib/angostura/version.rb +3 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35547437d58eaca9ec86406bf957db4f8582abe2
|
4
|
+
data.tar.gz: fa9b39acbebe8536980f790d276203c8c6bd0372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baf9b7a7683fb1ada10daa093f9d23cd75a389d123b7986058d1eb2f4555b05be94eed19bd93a294e74ac99074b0e7b2fd70ef86811f0809e7ef32c1ab8f74df
|
7
|
+
data.tar.gz: a4f0a38da7d883a0988afca7b23ed1f73d64943d88f1f0eecd4fbb447d7310421e502fe635c97292b954266e29c1cf7478bfb6a30be896a28c3c7ee1c8eb295d
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Angostura
|
2
|
+
module Dependencies
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
class_methods do
|
6
|
+
mattr_accessor :dependencies
|
7
|
+
|
8
|
+
def setup
|
9
|
+
yield self
|
10
|
+
|
11
|
+
dependencies.each do |dependency|
|
12
|
+
raise DependencyError.new(dependency) if self.send(dependency).nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def dependency(*args, **kargs)
|
17
|
+
self.dependencies = args + kargs&.keys
|
18
|
+
self.mattr_accessor(*dependencies)
|
19
|
+
|
20
|
+
kargs.each do |key, default_value|
|
21
|
+
self.send("#{key}=", default_value)
|
22
|
+
end
|
23
|
+
|
24
|
+
dependencies.each do |dependency|
|
25
|
+
define_singleton_method "#{dependency}_class" do
|
26
|
+
Object.const_get(self.send(dependency))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angostura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- justin
|
@@ -14,14 +14,14 @@ dependencies:
|
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -88,6 +88,9 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- lib/angostura.rb
|
91
|
+
- lib/angostura/dependencies.rb
|
92
|
+
- lib/angostura/dependency_error.rb
|
93
|
+
- lib/angostura/version.rb
|
91
94
|
homepage: https://github.com/justindoody/angostura
|
92
95
|
licenses:
|
93
96
|
- MIT
|