module Octo::FeatureFlag::ClassMethods

Public Instance Methods

featureflag(klass, state) click to toggle source

Set the featureflag for a module or class to the state. If the

featureflag is set to true, it means that the feature is disabled. If
the featureflag is set to false, it means that the feature is enabled.

It also defined a `is_flagged?` method on the module which returns
the state of featureflag

@param [Module] klass The class or module to be feature flagged @param [Boolean] state The boolean state to set for the class

# File lib/octocore-cassandra/featureflag.rb, line 26
def featureflag(klass, state)
  if state
    unless flags.include?klass
      flags << klass
      klass.instance_eval do
        def is_flagged?
          true
        end
      end
    end
  else
    if flags.include?klass
      flags.delete(klass)
      klass.instance_eval do
        def is_flagged?
          false
        end
      end
    end
  end
end
flags() click to toggle source

Get the list of all flags @return [Set] A set of all flags

# File lib/octocore-cassandra/featureflag.rb, line 51
def flags
  @flags ||= Set.new([])
end
is_flagged?() click to toggle source
# File lib/octocore-cassandra/featureflag.rb, line 31
def is_flagged?
  true
end
is_not_flagged?(feature) click to toggle source

Returns if the flag is not set @param [Module] feature The module to be tested @return [Boolean] Boolean value specifying the status

# File lib/octocore-cassandra/featureflag.rb, line 68
def is_not_flagged?(feature)
  !is_flagged?feature
end