ruje 0.0.1
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 +7 -0
- data/lib/controller.rb +8 -0
- data/lib/ruje/container.rb +4 -0
- data/lib/ruje/error/invalid_label.rb +6 -0
- data/lib/ruje/injectable.rb +25 -0
- data/lib/ruje/registerable.rb +19 -0
- data/lib/ruje.rb +11 -0
- metadata +48 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: bb96db84a4ea805e6e04f9a8f3664b80aa99ac1cbf9c0d69f08592c074733727
|
|
4
|
+
data.tar.gz: 3f3ed94d8b625621c9c6a26abd298450f0247ee8bdf6d8ccc0fe2fb4352ebdb9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ed577ae48ea7651cc46b58fc5812914b2d5851327c4604205343e3ea38b0dcb343a6e9f1facd3674728f1611efcb08a72bd8a606230836212afba4f7eb6c9e0d
|
|
7
|
+
data.tar.gz: 7f1167b56d571ae8e91732487f8cf9ff51bc4115a24c1d3ae9fc866552e70b7b3dba3d0d42e75171badef7288d81ee970b78c48229537abccc207f2447f782e2
|
data/lib/controller.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Ruje
|
|
2
|
+
module Injectable
|
|
3
|
+
|
|
4
|
+
# inject class into current class
|
|
5
|
+
# return the injected class
|
|
6
|
+
# inject(xxx).as(:xxx) will make a alias
|
|
7
|
+
def inject(label)
|
|
8
|
+
label = label.to_sym
|
|
9
|
+
define_method(label) do
|
|
10
|
+
Containers[_inject_from][label]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def initialize(*args)
|
|
15
|
+
super(*args)
|
|
16
|
+
inject_
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def inject_from(container)
|
|
20
|
+
define_method(:_inject_from) do
|
|
21
|
+
container.to_sym
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Ruje
|
|
2
|
+
module Registerable
|
|
3
|
+
# register current class as <label>
|
|
4
|
+
def register(container, label)
|
|
5
|
+
raise 'register only accept string or symbol' unless label in Symbol | String
|
|
6
|
+
|
|
7
|
+
container = container.to_sym
|
|
8
|
+
label = label.to_sym
|
|
9
|
+
|
|
10
|
+
# todo: make a duplicate registration error
|
|
11
|
+
if Ruje::Containers.has_key?(container) && Ruje::Containers[container].has_key?(label)
|
|
12
|
+
raise "#{label} in #{container} already registered"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Ruje::Containers[container] ||= {}
|
|
16
|
+
Ruje::Containers[container][label] ||= self.new
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/ruje.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ruje
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Pero Azuma
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-03-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: xxx
|
|
14
|
+
email: 0711kps@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/controller.rb
|
|
20
|
+
- lib/ruje.rb
|
|
21
|
+
- lib/ruje/container.rb
|
|
22
|
+
- lib/ruje/error/invalid_label.rb
|
|
23
|
+
- lib/ruje/injectable.rb
|
|
24
|
+
- lib/ruje/registerable.rb
|
|
25
|
+
homepage: https://rubygems.org/gems/inject-rb
|
|
26
|
+
licenses:
|
|
27
|
+
- MIT
|
|
28
|
+
metadata: {}
|
|
29
|
+
post_install_message:
|
|
30
|
+
rdoc_options: []
|
|
31
|
+
require_paths:
|
|
32
|
+
- lib
|
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
requirements: []
|
|
44
|
+
rubygems_version: 3.4.6
|
|
45
|
+
signing_key:
|
|
46
|
+
specification_version: 4
|
|
47
|
+
summary: make class injectable
|
|
48
|
+
test_files: []
|