glassy-kernel

DI (Dependency Injection) Container for the Glassy Framework

glassy-kernel

CircleCI

DI (Dependency Injection) Container for the Glassy Framework, based in bundles.

Inspired by: phoopy

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      glassy-kernel:
        github: glassy-framework/glassy-kernel
    
  2. 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

  1. Fork it (https://github.com/glassy-framework/glassy-kernel/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

glassy-kernel

Owner
Statistic
  • 3
  • 0
  • 0
  • 6
  • 0
  • over 3 years ago
  • August 15, 2020
License

MIT License

Links
Synced at

Thu, 18 Apr 2024 19:51:21 GMT

Languages