This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #474 from education/flipping-flippers
Add Flipper to Classroom
- Loading branch information
Showing
15 changed files
with
134 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Assignment < ActiveRecord::Base | ||
include Flippable | ||
include GitHubPlan | ||
include Sluggable | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Flippable | ||
extend ActiveSupport::Concern | ||
|
||
def flipper_id | ||
"#{self.class}:#{id}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class GroupAssignment < ActiveRecord::Base | ||
include Flippable | ||
include GitHubPlan | ||
include Sluggable | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<nav class="menu"> | ||
<span class="menu-heading"><%= octicon('rocket') %> Stafftools</span> | ||
<%= link_to stafftools_root_path, class: 'menu-item selected' do %> | ||
<%= octicon('search') %> | ||
Search | ||
<% end %> | ||
<span class="menu-heading"><%= octicon('rocket') %> Site Admin</span> | ||
<%= link_to 'Search', stafftools_root_path, class: 'menu-item selected' %> | ||
</nav> | ||
|
||
<nav class="menu"> | ||
<span class="menu-heading"><%= octicon('code') %> Developer Tools</span> | ||
<%= link_to 'Features', stafftools_flipper_path, class: 'menu-item' %> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Classroom | ||
REDIS_URL = ENV['REDISTOGO_URL'] || 'redis://localhost:6379/0' | ||
|
||
def self.redis | ||
@redis ||= Redis.new(url: REDIS_URL) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Classroom | ||
def self.flipper | ||
@flipper ||= self.flipper! | ||
end | ||
|
||
def self.flipper! | ||
adapter = if Rails.env.test? | ||
require 'flipper/adapters/memory' | ||
Flipper::Adapters::Memory.new | ||
else | ||
namespaced_client = Redis::Namespace.new(:flipper, :redis => Classroom.redis) | ||
Flipper::Adapters::Redis.new(namespaced_client) | ||
end | ||
|
||
Flipper.new(adapter) | ||
end | ||
end | ||
|
||
# Flipper group for staff | ||
Flipper.register(:staff) do |user| | ||
user.respond_to?(:staff?) && user.staff? | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters