Module: FuncLive

Defined in:
lib/func_live.rb,
lib/func_live/client.rb,
lib/func_live/version.rb

Defined Under Namespace

Classes: Client, Error

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.call(function_name, input = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/func_live.rb', line 30

def call(function_name, input = nil)
  response = client.functions(function_name, input)

  if response["success"] == false
    raise FuncLive::Error, response["error"]
  end

  response["output"]
end

.clientObject



26
27
28
# File 'lib/func_live.rb', line 26

def client
  @client ||= FuncLive::Client.new(token)
end

.default_tokenObject



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

def default_token
  ENV["FUNC_LIVE_TOKEN"]
end

.tokenObject



18
19
20
21
22
23
24
# File 'lib/func_live.rb', line 18

def token
  if @token.to_s.empty? && default_token.to_s.empty?
    raise FuncLive::Error, "FuncLive.token is empty"
  end

  @token || default_token
end

.token=(token) ⇒ Object

rubocop:disable Style/TrivialAccessors



14
15
16
# File 'lib/func_live.rb', line 14

def token=(token) # rubocop:disable Style/TrivialAccessors
  @token = token
end