
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Dependency injection principles and idioms realized in scope of Ruby. Support for method-injeciton strategy, container-based dependency resolving, static and dynamic bindings and etc.
method-injection
strategysoon:
constructor injection strategy;soon:
property injection strategy;gem 'smart_injection'
bundle install
# --- or ---
gem install smart_injection
require 'smart_core/injection'
Create some containers:
AppContainer = SmartCore::Container.define do
namespace(:data_storage) do
register(:main) { Sequel::Model.db }
register(:cache) { Redis.new }
end
end
ServiceContainer = SmartCore::Container.define do
namespace(:rands) do
register(:alphanum) { -> { SecureRandom.alphanumeric } }
register(:hex) { -> { SecureRandom.hex } }
end
end
GlobalContainer = SmartCore::Container.define do
namespace(:phone_clients) do
register(:nexmo) { Nexmo.new }
register(:twilio) { Twilio.new }
end
end
And work with dependency injection:
class MiniService
include SmartCore::Injection
register_container(AppContainer)
register_container(ServiceContainer)
# --- or ---
include SmartCore::Injection(AppContainer, ServiceContainer)
# --- or ---
include SmartCore::Injection
register_container(AppContainer, ServiceContainer)
# import dependencies to an instance
import({ db: 'data_storage.main' }, bind: :dynamic, access: :private)
import({ rnd: 'rands.alphanum' }, bind: :static, memoize: true)
# import dependencies to a class
import_static({ cache: 'data_storage.cache', hexer: 'rands.hex' }, bind: :static)
# import from a non-registered container
import({ phone_client: 'phone_clients.nexmo' }, from: GlobalContainer)
def call
db # => returns data_storage.main
rnd # => returns rands.alphanum
self.class.cache # => returns data_storage.cache
self.class.hexer # => returns rands.hexer
phone_client # => returns phone_clients.nexmo
end
end
SmartCore::Injection
module inclusion (in addition to default containers)bundle exce rake rspec
bundle exec rake rubocop
bundle exec rake rubocop -A
git checkout -b feature/my-new-feature
)git commit -am '[feature_context] Add some feature'
)git push origin feature/my-new-feature
)Released under MIT License.
FAQs
Unknown package
We found that smart_injection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.