module
Cryap::Container
Included Modules
- HardWire::Container
Defined in:
container.crConstant Summary
-
REGISTRATIONS =
[{type: "Cryap::AdminSocket::Socket", tag: "default", lifecycle: :singleton}, {type: "Cryap::Database::Driver", tag: "default", lifecycle: :singleton}, {type: "Cryap::Database::RedisDriver", tag: "default", lifecycle: :singleton}, {type: "Cryap::HttpServer", tag: "default", lifecycle: :singleton}, {type: "Cryap::StreamingService", tag: "default", lifecycle: :singleton}, {type: "Cryap::NotificationService", tag: "default", lifecycle: :singleton}, {type: "Cryap::ActivityPub::ServiceActor", tag: "default", lifecycle: :singleton}, {type: "Cryap::MediaService", tag: "default", lifecycle: :singleton}, {type: "Cryap::ActorsService", tag: "default", lifecycle: :singleton}, {type: "Cryap::DeliveryService", tag: "default", lifecycle: :singleton}, {type: "Cryap::UsersService", tag: "default", lifecycle: :singleton}, {type: "Cryap::PostsService", tag: "default", lifecycle: :singleton}, {type: "Cryap::SearchService", tag: "default", lifecycle: :singleton}, {type: "Cryap::FollowsService", tag: "default", lifecycle: :singleton}, {type: "Cryap::InboxService", tag: "default", lifecycle: :singleton}, {type: "Cryap::WebFinger::WebFingerService", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::RootController", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::AuthController", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::PostController", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::WebFingerController", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ActivityPubController", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::NodeInfoController", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::UsersController", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::UsersController::Followers", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::UsersController::Following", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::UsersController::Inbox", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::UsersController::Outbox", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ApiController::Accounts", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ApiController::Apps", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ApiController::Instance", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ApiController::Notifications", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ApiController::Search", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ApiController::Statuses", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ApiController::Streaming", tag: "default", lifecycle: :singleton}, {type: "Cryap::Web::ApiController::Timelines", tag: "default", lifecycle: :singleton}] of NamedTuple(type: String, tag: String, lifecycle: Symbol) -
Store all registrations, which are mainly used to give nice errors for duplicate registrations
Users can also run their own checks at runtime for length, structure, etc.
Class Method Summary
-
.destroy_scope(scope_name)
Destroy a scope's instances, leaving it able to be garbage collected
-
.has_scope?(scope_name) : Bool
Interrogate the container to determine whether a scope has been initialized NOTE: this only works if something has been resolved in scope before this method is called
-
.registered?(target : Class, tag = "default") : Bool
Interrogate the container for a registration
- .resolve!(type : Cryap::AdminSocket::Socket.class, tag : String, scope : String = "singleton") : Cryap::AdminSocket::Socket
- .resolve!(type : Cryap::Database::Driver.class, tag : String, scope : String = "singleton") : Cryap::Database::Driver
- .resolve!(type : Cryap::Database::RedisDriver.class, tag : String, scope : String = "singleton") : Cryap::Database::RedisDriver
- .resolve!(type : Cryap::HttpServer.class, tag : String, scope : String = "singleton") : Cryap::HttpServer
- .resolve!(type : Cryap::StreamingService.class, tag : String, scope : String = "singleton") : Cryap::StreamingService
- .resolve!(type : Cryap::NotificationService.class, tag : String, scope : String = "singleton") : Cryap::NotificationService
- .resolve!(type : Cryap::ActivityPub::ServiceActor.class, tag : String, scope : String = "singleton") : Cryap::ActivityPub::ServiceActor
- .resolve!(type : Cryap::MediaService.class, tag : String, scope : String = "singleton") : Cryap::MediaService
- .resolve!(type : Cryap::ActorsService.class, tag : String, scope : String = "singleton") : Cryap::ActorsService
- .resolve!(type : Cryap::DeliveryService.class, tag : String, scope : String = "singleton") : Cryap::DeliveryService
- .resolve!(type : Cryap::UsersService.class, tag : String, scope : String = "singleton") : Cryap::UsersService
- .resolve!(type : Cryap::PostsService.class, tag : String, scope : String = "singleton") : Cryap::PostsService
- .resolve!(type : Cryap::SearchService.class, tag : String, scope : String = "singleton") : Cryap::SearchService
- .resolve!(type : Cryap::FollowsService.class, tag : String, scope : String = "singleton") : Cryap::FollowsService
- .resolve!(type : Cryap::InboxService.class, tag : String, scope : String = "singleton") : Cryap::InboxService
- .resolve!(type : Cryap::WebFinger::WebFingerService.class, tag : String, scope : String = "singleton") : Cryap::WebFinger::WebFingerService
- .resolve!(type : Cryap::Web::RootController.class, tag : String, scope : String = "singleton") : Cryap::Web::RootController
- .resolve!(type : Cryap::Web::AuthController.class, tag : String, scope : String = "singleton") : Cryap::Web::AuthController
- .resolve!(type : Cryap::Web::PostController.class, tag : String, scope : String = "singleton") : Cryap::Web::PostController
- .resolve!(type : Cryap::Web::WebFingerController.class, tag : String, scope : String = "singleton") : Cryap::Web::WebFingerController
- .resolve!(type : Cryap::Web::ActivityPubController.class, tag : String, scope : String = "singleton") : Cryap::Web::ActivityPubController
- .resolve!(type : Cryap::Web::NodeInfoController.class, tag : String, scope : String = "singleton") : Cryap::Web::NodeInfoController
- .resolve!(type : Cryap::Web::UsersController.class, tag : String, scope : String = "singleton") : Cryap::Web::UsersController
- .resolve!(type : Cryap::Web::UsersController::Followers.class, tag : String, scope : String = "singleton") : Cryap::Web::UsersController::Followers
- .resolve!(type : Cryap::Web::UsersController::Following.class, tag : String, scope : String = "singleton") : Cryap::Web::UsersController::Following
- .resolve!(type : Cryap::Web::UsersController::Inbox.class, tag : String, scope : String = "singleton") : Cryap::Web::UsersController::Inbox
- .resolve!(type : Cryap::Web::UsersController::Outbox.class, tag : String, scope : String = "singleton") : Cryap::Web::UsersController::Outbox
- .resolve!(type : Cryap::Web::ApiController::Accounts.class, tag : String, scope : String = "singleton") : Cryap::Web::ApiController::Accounts
- .resolve!(type : Cryap::Web::ApiController::Apps.class, tag : String, scope : String = "singleton") : Cryap::Web::ApiController::Apps
- .resolve!(type : Cryap::Web::ApiController::Instance.class, tag : String, scope : String = "singleton") : Cryap::Web::ApiController::Instance
- .resolve!(type : Cryap::Web::ApiController::Notifications.class, tag : String, scope : String = "singleton") : Cryap::Web::ApiController::Notifications
- .resolve!(type : Cryap::Web::ApiController::Search.class, tag : String, scope : String = "singleton") : Cryap::Web::ApiController::Search
- .resolve!(type : Cryap::Web::ApiController::Statuses.class, tag : String, scope : String = "singleton") : Cryap::Web::ApiController::Statuses
- .resolve!(type : Cryap::Web::ApiController::Streaming.class, tag : String, scope : String = "singleton") : Cryap::Web::ApiController::Streaming
- .resolve!(type : Cryap::Web::ApiController::Timelines.class, tag : String, scope : String = "singleton") : Cryap::Web::ApiController::Timelines
Macro Summary
-
resolve(target, tag = "default")
Resolve a dependency from a class and a string tag
-
scope(name)
create a new scope with the specified name
-
scope
Create a new scope with a randomly chosen unique ID
-
scoped(path, tag = nil, &block)
Register a scoped dependency.
-
scoped(path, &block)
Register a singleton dependency.
-
singleton(path, tag = nil, &block)
Register a singleton dependency.
-
singleton(path, &block)
Register a singleton dependency.
-
transient(path, tag = nil, &block)
Register a transient dependency.
-
transient(path, &block)
Register a transient dependency.
Class Method Detail
Destroy a scope's instances, leaving it able to be garbage collected
Interrogate the container to determine whether a scope has been initialized
NOTE this only works if something has been resolved in scope before this method is called
Interrogate the container for a registration
Macro Detail
Resolve a dependency from a class and a string tag
This macro does the legwork of mangling the dynamic-looking call into the statically-defined .resolve! method
NOTE This method does not protect you from unregistered dependencies, since it relies on
directly resolving the .resolve! method. If you need safety - use .registered?