Class: Firefighter::RealtimeDatabase

Inherits:
Object
  • Object
show all
Includes:
Web
Defined in:
lib/firefighter/realtime_database.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Web

#call, #logger

Constructor Details

#initialize(db_name:, db_secret:) ⇒ RealtimeDatabase



13
14
15
16
# File 'lib/firefighter/realtime_database.rb', line 13

def initialize(db_name:, db_secret:)
  @db_name = db_name
  @db_secret = db_secret
end

Class Method Details

.from_envObject



5
6
7
8
9
10
11
# File 'lib/firefighter/realtime_database.rb', line 5

def self.from_env
  config = {
    db_name: ENV['FIREBASE_WEB_DB_NAME'],
    db_secret: ENV['FIREBASE_WEB_DB_SECRET']
  }
  new(config)
end

Instance Method Details

#add(path, data) ⇒ Object



23
24
25
26
# File 'lib/firefighter/realtime_database.rb', line 23

def add(path, data)
  url = endpoint(path)
  call(:post, url, data)
end

#read(path) ⇒ Object



28
29
30
31
# File 'lib/firefighter/realtime_database.rb', line 28

def read(path)
  url = endpoint(path)
  call(:get, url)
end

#write(path, data) ⇒ Object



18
19
20
21
# File 'lib/firefighter/realtime_database.rb', line 18

def write(path, data)
  url = endpoint(path)
  call(:put, url, data)
end