Class: Ardb::AdapterSpy

Inherits:
Ardb::Adapter::Base show all
Defined in:
lib/ardb/adapter_spy.rb

Instance Attribute Summary collapse

Attributes inherited from Ardb::Adapter::Base

#config

Instance Method Summary collapse

Methods inherited from Ardb::Adapter::Base

#==, #connect_hash, #database, #dump_ruby_schema, #dump_sql_schema, #escape_like_pattern, #load_ruby_schema, #load_sql_schema, #migrate_db_backward, #migrate_db_down, #migrate_db_forward, #migrate_db_up, #migrations_path, #ruby_schema_path, #schema_format, #sql_schema_path

Constructor Details

#initialize(config = nil) ⇒ AdapterSpy

Returns a new instance of AdapterSpy.



11
12
13
14
15
16
17
18
19
20
# File 'lib/ardb/adapter_spy.rb', line 11

def initialize(config = nil)
  super(config || Ardb::Config.new)
  @drop_tables_called_count = 0
  @dump_schema_called_count = 0
  @load_schema_called_count = 0
  @drop_db_called_count     = 0
  @create_db_called_count   = 0
  @connect_db_called_count  = 0
  @migrate_db_called_count  = 0
end

Instance Attribute Details

#connect_db_called_countObject

Returns the value of attribute connect_db_called_count.



9
10
11
# File 'lib/ardb/adapter_spy.rb', line 9

def connect_db_called_count
  @connect_db_called_count
end

#create_db_called_countObject

Returns the value of attribute create_db_called_count.



8
9
10
# File 'lib/ardb/adapter_spy.rb', line 8

def create_db_called_count
  @create_db_called_count
end

#drop_db_called_countObject

Returns the value of attribute drop_db_called_count.



8
9
10
# File 'lib/ardb/adapter_spy.rb', line 8

def drop_db_called_count
  @drop_db_called_count
end

#drop_tables_called_countObject

Returns the value of attribute drop_tables_called_count.



6
7
8
# File 'lib/ardb/adapter_spy.rb', line 6

def drop_tables_called_count
  @drop_tables_called_count
end

#dump_schema_called_countObject

Returns the value of attribute dump_schema_called_count.



7
8
9
# File 'lib/ardb/adapter_spy.rb', line 7

def dump_schema_called_count
  @dump_schema_called_count
end

#load_schema_called_countObject

Returns the value of attribute load_schema_called_count.



7
8
9
# File 'lib/ardb/adapter_spy.rb', line 7

def load_schema_called_count
  @load_schema_called_count
end

#migrate_db_called_countObject

Returns the value of attribute migrate_db_called_count.



9
10
11
# File 'lib/ardb/adapter_spy.rb', line 9

def migrate_db_called_count
  @migrate_db_called_count
end

Instance Method Details

#connect_db(*args, &block) ⇒ Object



64
65
66
# File 'lib/ardb/adapter_spy.rb', line 64

def connect_db(*args, &block)
  self.connect_db_called_count += 1
end

#connect_db_called?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/ardb/adapter_spy.rb', line 34

def connect_db_called?
  self.connect_db_called_count > 0
end

#create_db(*args, &block) ⇒ Object

Overwritten ‘Adapter::Base` methods



52
53
54
# File 'lib/ardb/adapter_spy.rb', line 52

def create_db(*args, &block)
  self.create_db_called_count += 1
end

#create_db_called?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ardb/adapter_spy.rb', line 22

def create_db_called?
  self.create_db_called_count > 0
end

#drop_db(*args, &block) ⇒ Object



56
57
58
# File 'lib/ardb/adapter_spy.rb', line 56

def drop_db(*args, &block)
  self.drop_db_called_count += 1
end

#drop_db_called?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ardb/adapter_spy.rb', line 26

def drop_db_called?
  self.drop_db_called_count > 0
end

#drop_tables(*args, &block) ⇒ Object



60
61
62
# File 'lib/ardb/adapter_spy.rb', line 60

def drop_tables(*args, &block)
  self.drop_tables_called_count += 1
end

#drop_tables_called?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ardb/adapter_spy.rb', line 30

def drop_tables_called?
  self.drop_tables_called_count > 0
end

#dump_schema(*args, &block) ⇒ Object



76
77
78
# File 'lib/ardb/adapter_spy.rb', line 76

def dump_schema(*args, &block)
  self.dump_schema_called_count += 1
end

#dump_schema_called?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/ardb/adapter_spy.rb', line 46

def dump_schema_called?
  self.dump_schema_called_count > 0
end

#load_schema(*args, &block) ⇒ Object



72
73
74
# File 'lib/ardb/adapter_spy.rb', line 72

def load_schema(*args, &block)
  self.load_schema_called_count += 1
end

#load_schema_called?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/ardb/adapter_spy.rb', line 42

def load_schema_called?
  self.load_schema_called_count > 0
end

#migrate_db(*args, &block) ⇒ Object



68
69
70
# File 'lib/ardb/adapter_spy.rb', line 68

def migrate_db(*args, &block)
  self.migrate_db_called_count += 1
end

#migrate_db_called?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/ardb/adapter_spy.rb', line 38

def migrate_db_called?
  self.migrate_db_called_count > 0
end