Skip to content

Commit

Permalink
Added Flipper.groups writer.
Browse files Browse the repository at this point in the history
In case people want to have their own registry for some weird reason.
  • Loading branch information
jnunemaker committed Aug 2, 2012
1 parent 34b6872 commit 94a4381
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/flipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def groups
@groups ||= Registry.new
end

def groups=(registry)
@groups = registry
end

def register(name, &block)
group = Types::Group.new(name, &block)
groups.add(group.name, group)
Expand Down
8 changes: 8 additions & 0 deletions spec/flipper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
end
end

describe ".groups=" do
it "sets groups registry" do
registry = Flipper::Registry.new
Flipper.groups = registry
Flipper.instance_variable_get("@groups").should eq(Flipper::Registry)
end
end

describe ".register" do
it "adds a group to the group_registry" do
group = Flipper.register(:admins) { |actor| actor.admin? }
Expand Down

0 comments on commit 94a4381

Please sign in to comment.