glassy-kernel
glassy-kernel
DI (Dependency Injection) Container for the Glassy Framework, based in bundles.
Inspired by: phoopy
Installation
-
Add the dependency to your
shard.yml
:dependencies: glassy-kernel: github: glassy-framework/glassy-kernel
-
Run
shards install
Usage
Create a dependency file, ex: config/services.yml
services:
my_object:
class: MyClass
kwargs:
logger: '@logger'
tag:
- my_tag_example
logger:
class: MyLogger
Implement these classes as you like. After that you can implement the container as below.
require "glassy-kernel"
class AppBundle < Glassy::Kernel::Bundle
SERVICES_PATH = "#{__DIR__}/config/services.yml"
end
class AppKernel < Glassy::Kernel::Kernel
register_bundles [
AppBundle
]
end
kernel = AppKernel.new
kernel.container.my_object.say_hello
Development
Always run crystal spec to execute the tests
Contributing
- Fork it (https://github.com/glassy-framework/glassy-kernel/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Anderson Danilo - creator and maintainer
Repository
glassy-kernel
Owner
Statistic
- 3
- 0
- 0
- 6
- 0
- about 4 years ago
- August 15, 2020
License
MIT License
Links
Synced at
Fri, 22 Nov 2024 00:38:31 GMT
Languages