Class: Flipper::Adapters::ActorLimit

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/flipper/adapters/actor_limit.rb

Constant Summary collapse

LimitExceeded =
Class.new(Flipper::Error)

Constants inherited from Wrapper

Wrapper::METHODS

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#adapter

Instance Method Summary collapse

Methods inherited from Wrapper

#wrap

Methods included from Flipper::Adapter

#default_config, #export, #get_all, #get_multi, #import, included, #name, #read_only?

Constructor Details

#initialize(adapter, limit = 100) ⇒ ActorLimit

Returns a new instance of ActorLimit.



8
9
10
11
# File 'lib/flipper/adapters/actor_limit.rb', line 8

def initialize(adapter, limit = 100)
  super(adapter)
  @limit = limit
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



6
7
8
# File 'lib/flipper/adapters/actor_limit.rb', line 6

def limit
  @limit
end

Instance Method Details

#enable(feature, gate, resource) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/flipper/adapters/actor_limit.rb', line 13

def enable(feature, gate, resource)
  if gate.is_a?(Flipper::Gates::Actor) && over_limit?(feature)
    raise LimitExceeded, "Actor limit of #{@limit} exceeded for feature #{feature.key}. See https://www.flippercloud.io/docs/features/actors#limitations"
  else
    super
  end
end