Sha256: 47f5c1324adbea589f97efc7e43644dc75fbedac188699accbac31c5dcc610d4

Contents?: true

Size: 606 Bytes

Versions: 5

Compression:

Stored size: 606 Bytes

Contents

module FeatureGate
  class GatedFeature < ActiveRecord::Base
    validates :name, presence: true
    validates :gated, inclusion: { in: [true, false] }

    scope :opened, -> { where(gated: false) }
    scope :closed, -> { where(gated: true) }
    scope :stale, -> { where('updated_at != created_at and updated_at < ?', Time.zone.now - FeatureGate.time_to_stale) }

    def deploy_feature!
      self.gated = false
      save!
    end

    def gate_feature!
      self.gated = true
      save!
    end

    def status
      if gated
        'closed'
      else
        'opened'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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