Skip to content

Commit

Permalink
add static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
miladrahimi committed Mar 31, 2021
1 parent bb8c963 commit 464345e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ func Reset() {
// It can take an abstraction (interface reference) and fill it with the related implementation.
// It also can takes a function (receiver) with one or more arguments of the abstractions (interfaces) that need to be
// resolved, Container will invoke the receiver function and pass the related implementations.
// Deprecated: Make is deprecated.
func Make(receiver interface{}) error {
return container.Make(receiver)
}

// Call takes a function with one or more arguments of the abstractions (interfaces) that need to be
// resolved, Container will invoke the receiver function and pass the related implementations.
func Call(receiver interface{}) error {
return container.Call(receiver)
}

// Bind takes an abstraction (interface reference) and fill it with the related implementation.
func Bind(receiver interface{}) error {
return container.Bind(receiver)
}

// Fill takes a struct and fills the fields with the tag `container:"inject"`
func Fill(receiver interface{}) error {
return container.Fill(receiver)
}
2 changes: 1 addition & 1 deletion pkg/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func TestContainer_Fill_With_Struct_Pointer(t *testing.T) {
assert.IsType(t, &MySQL{}, myApp.D)
}

func TestContainer_FillUnexported_With_Struct_Pointer(t *testing.T) {
func TestContainer_Fill_Unexported_With_Struct_Pointer(t *testing.T) {
err := instance.Singleton(func() Shape {
return &Circle{a: 5}
})
Expand Down

0 comments on commit 464345e

Please sign in to comment.