class OFFS

Constants

VERSION

Attributes

flag[R]
flag_status_checker[RW]
result[RW]

Public Class Methods

if_you_do_not_want_to(flag, flag_status_checker: nil, &block) click to toggle source
# File lib/offs.rb, line 17
def if_you_do_not_want_to(flag, flag_status_checker: nil, &block)
  so_you_want_to(flag, flag_status_checker: flag_status_checker) do |you|
    you.may_still_need_to(&block)
  end
end
if_you_would_like_to(flag, flag_status_checker: nil, &block) click to toggle source
# File lib/offs.rb, line 11
def if_you_would_like_to(flag, flag_status_checker: nil, &block)
  so_you_want_to(flag, flag_status_checker: flag_status_checker) do |you|
    you.would_like_to(&block)
  end
end
new(flag, flag_status_checker: nil) click to toggle source
# File lib/offs.rb, line 29
def initialize(flag, flag_status_checker: nil)
  self.flag_status_checker = flag_status_checker || Flags.instance
  self.flag = flag
end
raise_error_unless_we(flag, flag_status_checker: nil) click to toggle source
# File lib/offs.rb, line 23
def raise_error_unless_we(flag, flag_status_checker: nil)
  new(flag, flag_status_checker: flag_status_checker) \
    .raise_error_unless_we
end
so_you_want_to(flag, flag_status_checker: nil, &block) click to toggle source
# File lib/offs.rb, line 7
def so_you_want_to(flag, flag_status_checker: nil, &block)
  new(flag, flag_status_checker: flag_status_checker).so_you_want_to(&block)
end

Public Instance Methods

may_still_need_to(&block) click to toggle source
# File lib/offs.rb, line 43
def may_still_need_to(&block)
  when_flag(false, &block)
end
raise_error_unless_we() click to toggle source
# File lib/offs.rb, line 47
def raise_error_unless_we
  unless flag_enabled?
    raise FeatureDisabled,
      "Attempted to access code that is only available when the '#{flag}' " \
      + "feature is enabled, and it is currenlty disabled."
  end
end
so_you_want_to(&block) click to toggle source
# File lib/offs.rb, line 34
def so_you_want_to(&block)
  block.call(self)
  return result
end
would_like_to(&block) click to toggle source
# File lib/offs.rb, line 39
def would_like_to(&block)
  when_flag(true, &block)
end

Private Instance Methods

flag=(new_flag) click to toggle source
# File lib/offs.rb, line 60
def flag=(new_flag)
  flag_status_checker.validate!(new_flag)
  @flag = new_flag
end
flag_enabled?() click to toggle source
# File lib/offs.rb, line 69
def flag_enabled?
  flag_status_checker.enabled?(flag)
end
when_flag(bool, &block) click to toggle source
# File lib/offs.rb, line 65
def when_flag(bool, &block)
  self.result = block.call if flag_enabled? == bool
end