New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dependency_injection-sinatra

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency_injection-sinatra

  • 0.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Dependency Injection for Sinatra

Sinatra::DependencyInjection adds a helper method, called container, to access to your ruby dependency injection container

Installation

Just add the gem to your Gemfile

gem 'dependency_injection-sinatra'

Or simply install it using rubygems:

gem install dependency_injection-sinatra

Usage

Classic Application

In a classic application simply require the helper, and start using it:

require 'sinatra'
require 'sinatra/dependency_injection'

# define a route that uses the helper
get '/' do
  json container.get('awesome_service').find_trending
end

# The rest of your classic application code goes here...

Modular Application

In a modular application you need to require the helper, and then tell the application you will use it:

require 'sinatra/base'
require 'sinatra/dependency_injection'

class MyApp < Sinatra::Base
  register Sinatra::DependencyInjection

  # define a route that uses the helper
  get '/' do
    json container.get('awesome_service').find_trending
  end

  # The rest of your modular application code goes here...
end

Configuration path

By default it will try to load services.yml configuration file, but if your configuration file is stored in another place, you can easily change it:

require 'sinatra/base'
require 'sinatra/dependency_injection'

class MyApp < Sinatra::Base
  register Sinatra::DependencyInjection

  dependency_injection_path 'config/services.yml'

  # The rest of your module application code goes here...
end

FAQs

Package last updated on 29 Mar 2014

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc