Sha256: 2b44fbb36a9cbc9285b93aa5a3f8e9e8d91c4d45435284643ac420bbc9ed4b02

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

class GreenFlag::Admin::FeaturesController < ApplicationController

  layout 'green_flag/application'

  def index
    @features = GreenFlag::Feature.order(:created_at).all
  end

  def show
    @feature = GreenFlag::Feature.find(params[:id])
    @visitor_groups = GreenFlag::VisitorGroup.all.map { |group| { key: group.key, description: group.description } }
  end

  def current_visitor_status
    @feature = GreenFlag::Feature.find(params[:id])
    fd = GreenFlag::FeatureDecision.for_feature(@feature.id).where(site_visitor_id: current_site_visitor.id).first
    render :json => { status: status_text(fd) }
  end

private

  def status_text(feature_decison)
    if feature_decison.nil? || feature_decison.undecided?
      "Undecided"
    elsif feature_decison.enabled?
      "Enabled"
    else
      "Disabled"
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
green_flag-0.2.0 app/controllers/green_flag/admin/features_controller.rb