class Firebase::Admin::Config

Configuration options used to initialize an App.

Attributes

project_id[R]
service_account_id[R]

Public Class Methods

from_env() click to toggle source

Loads a configuration using the FIREBASE_CONFIG environment variable.

If the value of the FIREBASE_CONFIG environment variable starts with “{” it is parsed as a JSON object, otherwise it is interpreted as a path to the config file.

@return [Firebase::Admin::Config]

# File lib/firebase/admin/config.rb, line 19
def from_env
  config = ENV[FIREBASE_CONFIG_ENV_VAR]
  return new if config.nil?
  return from_json(config) if config.start_with?("{")
  from_file(config)
end
from_file(file) click to toggle source

Loads a configuration from a file.

@param [File, String] file

The path of the configuration file.

@return [Firebase::Admin::Config]

# File lib/firebase/admin/config.rb, line 32
def from_file(file)
  json = file.is_a?(File) ? file.read : File.read(file)
  from_json(json)
end
from_json(json) click to toggle source

Loads a configuration from JSON.

@param [String] json

A configuration encoded as a JSON string.

@return [Firebase::Admin::Config]

# File lib/firebase/admin/config.rb, line 43
def from_json(json)
  data = JSON.parse(json)
  new(
    project_id: data["projectId"],
    service_account_id: data["serviceAccountId"]
  )
end
new(project_id: nil, service_account_id: nil) click to toggle source

Initializes the configuration object.

# File lib/firebase/admin/config.rb, line 53
def initialize(project_id: nil, service_account_id: nil)
  @project_id = project_id
  @service_account_id = service_account_id
end