Class: Flipper::Adapters::DualWrite

Inherits:
Object
  • Object
show all
Includes:
Flipper::Adapter
Defined in:
lib/flipper/adapters/dual_write.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Flipper::Adapter

#default_config, #export, #import, included, #name

Constructor Details

#initialize(local, remote, options = {}) ⇒ DualWrite

Public: Build a new sync instance.

local - The local flipper adapter that should serve reads. remote - The remote flipper adapter that writes should go to first (in

addition to the local adapter).


13
14
15
16
# File 'lib/flipper/adapters/dual_write.rb', line 13

def initialize(local, remote, options = {})
  @local = local
  @remote = remote
end

Instance Attribute Details

#localObject (readonly)

Returns the value of attribute local.



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

def local
  @local
end

#remoteObject (readonly)

Returns the value of attribute remote.



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

def remote
  @remote
end

Instance Method Details

#add(feature) ⇒ Object



34
35
36
# File 'lib/flipper/adapters/dual_write.rb', line 34

def add(feature)
  @remote.add(feature).tap { @local.add(feature) }
end

#clear(feature) ⇒ Object



42
43
44
# File 'lib/flipper/adapters/dual_write.rb', line 42

def clear(feature)
  @remote.clear(feature).tap { @local.clear(feature) }
end

#disable(feature, gate, thing) ⇒ Object



52
53
54
55
56
# File 'lib/flipper/adapters/dual_write.rb', line 52

def disable(feature, gate, thing)
  @remote.disable(feature, gate, thing).tap do
    @local.disable(feature, gate, thing)
  end
end

#enable(feature, gate, thing) ⇒ Object



46
47
48
49
50
# File 'lib/flipper/adapters/dual_write.rb', line 46

def enable(feature, gate, thing)
  @remote.enable(feature, gate, thing).tap do
    @local.enable(feature, gate, thing)
  end
end

#featuresObject



18
19
20
# File 'lib/flipper/adapters/dual_write.rb', line 18

def features
  @local.features
end

#get(feature) ⇒ Object



22
23
24
# File 'lib/flipper/adapters/dual_write.rb', line 22

def get(feature)
  @local.get(feature)
end

#get_allObject



30
31
32
# File 'lib/flipper/adapters/dual_write.rb', line 30

def get_all
  @local.get_all
end

#get_multi(features) ⇒ Object



26
27
28
# File 'lib/flipper/adapters/dual_write.rb', line 26

def get_multi(features)
  @local.get_multi(features)
end

#remove(feature) ⇒ Object



38
39
40
# File 'lib/flipper/adapters/dual_write.rb', line 38

def remove(feature)
  @remote.remove(feature).tap { @local.remove(feature) }
end