Module: Changebase

Defined in:
lib/changebase.rb,
lib/changebase/version.rb,
lib/changebase/connection.rb

Defined Under Namespace

Modules: ActionController, ActiveRecord, Inline, Replication Classes: Connection, Engine, Exception, ServerError

Constant Summary collapse

VERSION =
'0.2'

Class Method Summary collapse

Class Method Details

.configure(**config) ⇒ Object



41
42
43
44
# File 'lib/changebase.rb', line 41

def self.configure(**config)
  @config.merge!(config)
  self.logger = @config[:logger] if @config[:logger]
end

.configured?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
# File 'lib/changebase.rb', line 46

def self.configured?
  case @config[:mode]
  when 'inline'
    !!@config[:connection]
  else
    true
  end
end

.connectionObject



35
36
37
38
39
# File 'lib/changebase.rb', line 35

def self.connection
  Thread.current[:changebase_connection] ||= Changebase::Connection.new({
    url: @config[:connection]
  })
end

.connection=(value) ⇒ Object



31
32
33
# File 'lib/changebase.rb', line 31

def self.connection=(value)
  @config[:connection] = value
end

.loggerObject



55
56
57
58
59
# File 'lib/changebase.rb', line 55

def self.logger
  return @logger if defined?(@logger)

  @logger = Logger.new(STDOUT)
end

.logger=(logger) ⇒ Object



61
62
63
# File 'lib/changebase.rb', line 61

def self.logger=(logger)
  @logger = logger
end

.metadata_tableObject



19
20
21
# File 'lib/changebase.rb', line 19

def self.
  @config[:metadata_table]
end

.metadata_table=(value) ⇒ Object



15
16
17
# File 'lib/changebase.rb', line 15

def self.(value)
  @config[:metadata_table] = value
end

.modeObject



27
28
29
# File 'lib/changebase.rb', line 27

def self.mode
  @config[:mode]
end

.mode=(value) ⇒ Object



23
24
25
# File 'lib/changebase.rb', line 23

def self.mode=(value)
  @config[:mode] = value
end