Sha256: f895664cdfd898fe7d2cb194d7b62e3bbecc8050e3ea65ca571f54809ac836be

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

require 'active_support/dependencies'

module FeatureGate
  # Our host application root path
  # We set this when the engine is initialized
  mattr_accessor :app_root

  # Yield self on setup for nice config blocks
  def self.setup
    yield self
  end

  def self.gate_page(name)
    gated_feature = GatedFeature.where(name: name).first_or_create
    if gated_feature.gated?
      raise ActiveRecord::RecordNotFound
    end
  end

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

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

  def self.turn_off!(name)
    gated_feature = GatedFeature.find_by_name!(name)
    gated_feature.turn_on!
  end
end

require 'feature_gate/engine'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feature_gate-0.0.6 lib/feature_gate.rb