Class: BBFlow::Persistent::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/bb_flow/persistent.rb

Constant Summary collapse

FILE_NAME =
'.bb_flow'
DIRS =
{ global: ENV['HOME'], local: Dir.pwd }

Class Method Summary collapse

Class Method Details

.get(name) ⇒ YAML::Store

Parameters:

  • name (Symbol)

Returns:

  • (YAML::Store)


66
67
68
69
# File 'lib/bb_flow/persistent.rb', line 66

def self.get(name)
  @memo ||= {}
  @memo[name] ||= YAML::Store.new(location(name))
end

.location(storage_type) ⇒ Object



71
72
73
74
75
# File 'lib/bb_flow/persistent.rb', line 71

def self.location(storage_type)
  fail "Unknown store: #{storage_type}" unless DIRS.keys.include?(storage_type)

  File.join(DIRS[storage_type], FILE_NAME)
end