update feature_flagger to have access to current user
This commit is contained in:
parent
169fc743d5
commit
59917e95ab
3 changed files with 11 additions and 6 deletions
|
|
@ -16,7 +16,8 @@ class PostsController < ApplicationController
|
|||
:xml
|
||||
|
||||
def new
|
||||
redirect_to "/stream" and return unless FeatureFlags.new_publisher
|
||||
@feature_flag = FeatureFlagger.new(current_user) #I should be a global before filter so @feature_flag is accessible
|
||||
redirect_to "/stream" and return unless @feature_flag.new_publisher?
|
||||
render :text => "", :layout => true
|
||||
end
|
||||
|
||||
|
|
|
|||
9
app/models/feature_flagger.rb
Normal file
9
app/models/feature_flagger.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class FeatureFlagger
|
||||
def initialize(current_user)
|
||||
@current_user = current_user
|
||||
end
|
||||
|
||||
def new_publisher?
|
||||
@current_user.admin? || !(Rails.env.production? || Rails.env.staging?)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
module FeatureFlags
|
||||
def self.new_publisher
|
||||
!(Rails.env.production? || Rails.env.staging?)
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue