Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Put BUILD in Baggy/Setty role, so we can further simplify KeyBag/KeySet
  • Loading branch information
lizmat committed Sep 8, 2013
1 parent f45940a commit 57caee6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/core/Baggy.pm
Expand Up @@ -2,6 +2,8 @@ my role Baggy does Associative {
has %!elems; # should be UInt

#- specific methods for users of role ------------------------------------------
method BUILD (:%!elems) {}

method at_key($k) {
Proxy.new(
FETCH => {
Expand Down
4 changes: 0 additions & 4 deletions src/core/KeyBag.pm
@@ -1,9 +1,5 @@
my class KeyBag does Baggy {

submethod BUILD (:%elems) {
nqp::bindattr(self, KeyBag, '%!elems', %elems);
}

method Bag { Bag.new-fp(nqp::getattr(self, KeyBag, '%!elems').values) }
method KeyBag { self }
}
4 changes: 0 additions & 4 deletions src/core/KeySet.pm
@@ -1,9 +1,5 @@
my class KeySet does Setty {

submethod BUILD (:%elems) {
nqp::bindattr(self, KeySet, '%!elems', %elems);
}

method Set { Set.new(self.keys) }
method KeySet { self }
}
2 changes: 2 additions & 0 deletions src/core/Setty.pm
Expand Up @@ -2,6 +2,8 @@ my role Setty does Associative {
has %!elems;

#- specific methods for users of role ------------------------------------------
method BUILD (:%!elems) {}

method at_key($k --> Bool) {
Proxy.new(
FETCH => {
Expand Down

0 comments on commit 57caee6

Please sign in to comment.