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, #migrations_path, #ruby_schema_path, #schema_format, #sql_schema_path

Constructor Details

#initialize(config = nil) ⇒ AdapterSpy

Returns a new instance of AdapterSpy.



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

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.



11
12
13
# File 'lib/ardb/adapter_spy.rb', line 11

def connect_db_called_count
  @connect_db_called_count
end

#create_db_called_countObject

Returns the value of attribute create_db_called_count.



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

def create_db_called_count
  @create_db_called_count
end

#drop_db_called_countObject

Returns the value of attribute drop_db_called_count.



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

def drop_db_called_count
  @drop_db_called_count
end

#drop_tables_called_countObject

Returns the value of attribute drop_tables_called_count.



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

def drop_tables_called_count
  @drop_tables_called_count
end

#dump_schema_called_countObject

Returns the value of attribute dump_schema_called_count.



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

def dump_schema_called_count
  @dump_schema_called_count
end

#load_schema_called_countObject

Returns the value of attribute load_schema_called_count.



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

def load_schema_called_count
  @load_schema_called_count
end

#migrate_db_called_countObject

Returns the value of attribute migrate_db_called_count.



11
12
13
# File 'lib/ardb/adapter_spy.rb', line 11

def migrate_db_called_count
  @migrate_db_called_count
end

Instance Method Details

#connect_db(*args, &block) ⇒ Object



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

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

#connect_db_called?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/ardb/adapter_spy.rb', line 36

def connect_db_called?
  self.connect_db_called_count > 0
end

#create_db(*args, &block) ⇒ Object



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

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

#create_db_called?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ardb/adapter_spy.rb', line 24

def create_db_called?
  self.create_db_called_count > 0
end

#drop_db(*args, &block) ⇒ Object



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

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

#drop_db_called?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ardb/adapter_spy.rb', line 28

def drop_db_called?
  self.drop_db_called_count > 0
end

#drop_tables(*args, &block) ⇒ Object



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

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

#drop_tables_called?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/ardb/adapter_spy.rb', line 32

def drop_tables_called?
  self.drop_tables_called_count > 0
end

#dump_schema(*args, &block) ⇒ Object



88
89
90
# File 'lib/ardb/adapter_spy.rb', line 88

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

#dump_schema_called?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/ardb/adapter_spy.rb', line 48

def dump_schema_called?
  self.dump_schema_called_count > 0
end

#foreign_key_add_sqlObject

Overwritten ‘Adapter::Base` methods



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

def foreign_key_add_sql
  "FAKE ADD FOREIGN KEY SQL :from_table :from_column " \
  ":to_table :to_column :name"
end

#foreign_key_drop_sqlObject



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

def foreign_key_drop_sql
  "FAKE DROP FOREIGN KEY SQL :from_table :from_column " \
  ":to_table :to_column :name"
end

#load_schema(*args, &block) ⇒ Object



84
85
86
# File 'lib/ardb/adapter_spy.rb', line 84

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

#load_schema_called?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/ardb/adapter_spy.rb', line 44

def load_schema_called?
  self.load_schema_called_count > 0
end

#migrate_db(*args, &block) ⇒ Object



80
81
82
# File 'lib/ardb/adapter_spy.rb', line 80

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

#migrate_db_called?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/ardb/adapter_spy.rb', line 40

def migrate_db_called?
  self.migrate_db_called_count > 0
end