Class: ActiveGroonga::TestFixtures::ConnectionMock — activegroonga - ラングバ

Class: ActiveGroonga::TestFixtures::ConnectionMock

Inherits:
Object
  • Object
show all
Defined in:
lib/active_groonga/fixtures.rb

Instance Method Summary (collapse)

Constructor Details

- (ConnectionMock) initialize

Returns a new instance of ConnectionMock



55
56
57
# File 'lib/active_groonga/fixtures.rb', line 55

def initialize
  @last_quoted_table_name = nil
end

Instance Method Details

- (Object) delete(sql, name = nil)



72
73
74
75
76
# File 'lib/active_groonga/fixtures.rb', line 72

def delete(sql, name=nil)
  if @last_quoted_table_name
    Base.context[@last_quoted_table_name].truncate
  end
end

- (Object) disable_referential_integrity



59
60
61
# File 'lib/active_groonga/fixtures.rb', line 59

def disable_referential_integrity
  yield
end

- (Object) insert_fixture(fixture, table_name)



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/active_groonga/fixtures.rb', line 78

def insert_fixture(fixture, table_name)
  table = Base.context[Base.groonga_table_name(table_name)]
  record = table.add

  row = fixture.to_hash

  fixture.each do |key, value|
    record[key] = value
  end

  row[fixture.model_class.primary_key] = record.id
end

- (Object) quote_table_name(table_name)



67
68
69
70
# File 'lib/active_groonga/fixtures.rb', line 67

def quote_table_name(table_name)
  @last_quoted_table_name = Base.groonga_table_name(table_name)
  table_name
end

- (Object) transaction(options = nil)



63
64
65
# File 'lib/active_groonga/fixtures.rb', line 63

def transaction(options=nil)
  yield
end