Class: FaaStRuby::Local::RubyFunction

Inherits:
Function show all
Includes:
Logger
Defined in:
lib/faastruby/local/functions/ruby.rb

Instance Attribute Summary

Attributes inherited from Function

#context, #created_at, #errors, #name, #updated_at, #workspace

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

#debug, puts, #puts

Methods inherited from Function

#destroy, #run, #update

Methods inherited from BaseObject

#assign_attributes, #attributes=, #call_api, #initialize, #mass_assign

Constructor Details

This class inherits a constructor from FaaStRuby::BaseObject

Class Method Details

.default_gemfileObject



6
7
8
9
# File 'lib/faastruby/local/functions/ruby.rb', line 6

def self.default_gemfile
  faastruby_rpc_version = Gem::DependencyList.from_specs.select{|d| d.name == 'faastruby-rpc'}[0]&.version || '0.2.3'
  "source 'https://rubygems.org'\n"
end

Instance Method Details

#write_handlerObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/faastruby/local/functions/ruby.rb', line 20

def write_handler
  debug "write_handler"
  content = "def handler(event)\n  # Write code here\n  \nend"
  file = "#{@absolute_folder}/handler.rb"
  if File.size(file) > 0
    puts "New Ruby function '#{@name}' detected."
  else
    File.write(file, content)
    puts "New Ruby function '#{@name}' initialized."
  end
end

#yaml_hashObject



11
12
13
14
15
16
17
18
# File 'lib/faastruby/local/functions/ruby.rb', line 11

def yaml_hash
  debug "yaml_hash"
  hash = {
    'cli_version' => FaaStRuby::VERSION,
    'name' => @name,
    'runtime' => DEFAULT_RUBY_RUNTIME
  }
end