Using EmbedHandler
The easiest way to access EmbedHanlder methods is to embed them into the object that you want to embed into other objects:
local EmbedHandler = LibStub("EmbedHandler-1.0") EmbedHandler:Embed(MyObject)
But you may also set EmbedHandler as a local variable and use it to embed objects into others:
EmbedHandler.Embed(MyObject, TargetObject)
Embedding Objects
There are two methods which can be used to embed objects into others. Most of the times you will want to use Embed, which embeds any methods from the object into the given target:
function MyObject:SomeMethod() -- Some Method end function MyObject:OtherMethod() -- Other Method end function MyObject:AnotherMethod() -- Another Method end -- Embed all methods from MyObject into "MyTarget" MyObject:Embed(MyTarget)
If you want to embed many methods into the target, but not all of them, you may provide exceptions:
function MyObject:SomeMethod() -- Some Method end function MyObject:OtherMethod() -- Other Method end function MyObject:AnotherMethod() -- Another Method end -- Embed all methods from MyObject (except "AnotherMethod") into "MyTarget" MyObject:Embed(MyTarget, "AnotherMethod")
However, if you only want to embed some specific methods into the target, then you should use SpecificEmbed:
function MyObject:SomeMethod() -- Some Method end function MyObject:OtherMethod() -- Other Method end function MyObject:AnotherMethod() -- Another Method end -- Embed "SomeMethod" into "MyTarget" MyObject:SpecificEmbed(MyTarget, "SomeMethod")
Facts
- Date created
- 05 Aug 2009
- Last updated
- 09 Dec 2009