Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Last active October 6, 2015 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoelzro/3071368 to your computer and use it in GitHub Desktop.
Save hoelzro/3071368 to your computer and use it in GitHub Desktop.
class Hexe::Stanza::Presence {
method new($obj) {
return self.bless(*);
}
}
class Hexe::Stanza::Message {
method new($obj) {
return self.bless(*);
}
}
class Hexe::Stanza {
method create($obj) {
given $obj<_tag> {
when 'presence' {
return Hexe::Stanza::Presence.new($obj);
}
when 'message' {
return Hexe::Stanza::Message.new($obj);
}
default {
return Failure("Unknown tag '$obj<_tag>'");
}
}
}
}
@timo
Copy link

timo commented Jan 17, 2014

don't forget that bless with a whatever star argument is now deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment