Class: RolloutPostgresStore

Inherits:
Object
  • Object
show all
Defined in:
lib/rollout_postgres_store.rb,
lib/rollout_postgres_store/version.rb

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Constructor Details

#initialize(model, attribute) ⇒ RolloutPostgresStore

Returns a new instance of RolloutPostgresStore.



2
3
4
5
# File 'lib/rollout_postgres_store.rb', line 2

def initialize(model, attribute)
  @model = model
  @attribute = attribute
end

Instance Method Details

#del(key) ⇒ Object



23
24
25
26
27
# File 'lib/rollout_postgres_store.rb', line 23

def del(key)
  if flag = @model.where("#{@attribute} ? '#{key}'").first
    flag.delete
  end
end

#get(key) ⇒ Object



7
8
9
10
11
# File 'lib/rollout_postgres_store.rb', line 7

def get(key)
  if flag = @model.where("#{@attribute} ? '#{key}'").first
    flag.send(@attribute)[key]
  end
end

#set(key, value) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/rollout_postgres_store.rb', line 13

def set(key, value)
  current = get(key)

  if current.nil?
    create_feature_flag(key, value)
  else
    update_flag(key, value)
  end
end