Sha256: 840ee56ff97ef2d3c99605c8c73e2b02fbf476df6e4a0f05bdc99f7f706aea58

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

class Object
  raise 'Abstract feature branch conflicts with another Ruby library' if respond_to?(:feature_branch)
  def self.feature_branch(feature_name, user_id = nil, &feature_work)
    if feature_enabled?(feature_name, user_id)
      feature_work.call
    end
  end

  raise 'Abstract feature branch conflicts with another Ruby library' if respond_to?(:feature_enabled?)
  def self.feature_enabled?(feature_name, user_id = nil)
    normalized_feature_name = feature_name.to_s.downcase

    value = AbstractFeatureBranch.application_features[normalized_feature_name]
    if value == 'per_user'
      value = AbstractFeatureBranch.user_features_storage.sismember("#{AbstractFeatureBranch::ENV_FEATURE_PREFIX}#{normalized_feature_name}", user_id)
    end
    value
  end

  raise 'Abstract feature branch conflicts with another Ruby library' if Object.new.respond_to?(:feature_branch)
  def feature_branch(feature_name, user_id = nil, &feature_work)
    Object.feature_branch(feature_name.to_s, user_id, &feature_work)
  end

  raise 'Abstract feature branch conflicts with another Ruby library' if Object.new.respond_to?(:feature_enabled?)
  def feature_enabled?(feature_name, user_id = nil)
    Object.feature_enabled?(feature_name.to_s, user_id)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
abstract_feature_branch-1.2.2 lib/ext/feature_branch.rb
abstract_feature_branch-1.2.1 lib/ext/feature_branch.rb
abstract_feature_branch-1.2.0 lib/ext/feature_branch.rb