Socket
Book a DemoInstallSign in
Socket

yadi

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yadi

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Yet another dependency injection container.

Why?

  • No need to pre-fill container
  • Classes can be used without a container

Usage

Auto-inject classes

class Foo; end
class Bar; end

class Baz
  # this tells to inject Foo instance as first argument and Bar as bar: option
  include Yadi::Inject('Foo', bar: 'Bar')
  def initialize(foo, bar:)
    @foo, @bar = foo, bar
  end
end

container = Yadi::Container.new
baz = container.make('Baz')

# this gives the same result
baz = Baz.new(Foo.new, bar: Bar.new)

Auto-inject in service container style

class Foo; end
class Bar; end

class Baz
  # this tells to inject values from container
  include Yadi::Inject('service.foo', bar: 'config.bar')
  def initialize(foo, bar:)
    @foo, @bar = foo, bar
  end
end

container = Yadi::Container.new
container['service.foo'] = Foo.new
container['config.bar'] = 'bar'
baz = container.make('Baz')

# this gives the same result
baz = Baz.new(Foo.new, bar: 'bar')

Installation

Add this line to your application's Gemfile:

gem 'yadi'

And then execute:

$ bundle

Or install it yourself as:

$ gem install yadi

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/appelsin/yadi.

FAQs

Package last updated on 02 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.