Sha256: 9d1177eb6159bc29404128f78e60ac6fc69949591bc89bcaebeb2c7374201668

Contents?: true

Size: 879 Bytes

Versions: 6

Compression:

Stored size: 879 Bytes

Contents

module FeatureGate
  class Manager
    def self.gate_page(name)
      gated_feature = GatedFeature.where(name: name).first_or_create
      if gated_feature.gated?
        raise ActionController::RoutingError.new('Not Found')
      end
    end

    def self.gate(name)
      gated_feature = GatedFeature.where(name: name).first_or_create
      if !gated_feature.gated?
        yield
      end
    end

    def self.opened_gates
      GatedFeature.opened.pluck(:name)
    end

    def self.closed_gates
      GatedFeature.closed.pluck(:name)
    end

    def self.stale_gates
      GatedFeature.stale.pluck(:name)
    end

    def self.open!(name)
      gated_feature = GatedFeature.find_by_name!(name)
      gated_feature.deploy_feature!
    end

    def self.close!(name)
      gated_feature = GatedFeature.find_by_name!(name)
      gated_feature.gate_feature!
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
feature_gate-0.1.9 app/models/feature_gate/manager.rb
feature_gate-0.1.8 app/models/feature_gate/manager.rb
feature_gate-0.1.7 app/models/feature_gate/manager.rb
feature_gate-0.1.6 app/models/feature_gate/manager.rb
feature_gate-0.1.5 app/models/feature_gate/manager.rb
feature_gate-0.1.4 app/models/feature_gate/manager.rb