Class: GatewaySignup::Engines::Sqlite

Inherits:
Object
  • Object
show all
Defined in:
lib/gateway_signup/engines/sqlite.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Sqlite

Returns a new instance of Sqlite.



6
7
8
# File 'lib/gateway_signup/engines/sqlite.rb', line 6

def initialize(args)
  @db = Sqlite3::Database.new args[:db]
end

Instance Method Details

#details(gateway) ⇒ Object



24
25
26
# File 'lib/gateway_signup/engines/sqlite.rb', line 24

def details(gateway)
  
end

#fields_for(gateway) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/gateway_signup/engines/sqlite.rb', line 28

def fields_for(gateway)
  id = @db.execute "select id from gateways where name = ?", gateway

  @db.execute <<-SQL
    select * from fields
      left outer join gateways_fields
      on gateways_fields.field_id = fields.id
      where gateways_fields.gateway_id = ?;
  SQL
end

#gatewaysObject



14
15
16
17
18
19
20
21
22
# File 'lib/gateway_signup/engines/sqlite.rb', line 14

def gateways
  results = []

  @db.execute("select * from gateways") do |row|
    results << row[:name]
  end

  results
end

#setup_db(force) ⇒ Object



10
11
12
# File 'lib/gateway_signup/engines/sqlite.rb', line 10

def setup_db(force)
  force ? force_create : soft_create
end