Sha256: 09b6acb537819cb5e134ad5da2d386ecbc2ebb98ff6b80e36dd351cfead4ccd0

Contents?: true

Size: 807 Bytes

Versions: 6

Compression:

Stored size: 807 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.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.3 app/models/feature_gate/manager.rb
feature_gate-0.1.2 app/models/feature_gate/manager.rb
feature_gate-0.1.1 app/models/feature_gate/manager.rb
feature_gate-0.1.0 app/models/feature_gate/manager.rb
feature_gate-0.0.9 app/models/feature_gate/manager.rb
feature_gate-0.0.8 app/models/feature_gate/manager.rb