Sha256: ead222879ce76ed267bbd2c97e77280e1e733fcf872497374b983cfbed202b1a

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

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

    def self.destroy!(name)
      gate = GatedFeature.find_by_name!(name)
      if gate.destroyable?
        gate.destroy!
        puts "#{gate.name} destroyed"
      else
        puts "#{gate.name} is currently being used in the codebase, execute `feature_gate_cleaner #{gate.name}` in the terminal to remove all references to #{gate.name}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
feature_gate-0.2.6 app/models/feature_gate/manager.rb
feature_gate-0.2.5 app/models/feature_gate/manager.rb
feature_gate-0.2.4 app/models/feature_gate/manager.rb
feature_gate-0.2.3 app/models/feature_gate/manager.rb
feature_gate-0.2.2 app/models/feature_gate/manager.rb
feature_gate-0.2.1 app/models/feature_gate/manager.rb
feature_gate-0.2.0 app/models/feature_gate/manager.rb