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

Instance Method Summary collapse

Methods included from Logger

#debug, #print, puts, #puts

Methods inherited from Function

#destroy, #run, #update

Methods inherited from BaseObject

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

Constructor Details

This class inherits a constructor from FaaStRuby::BaseObject

Instance Method Details

#write_handlerObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/faastruby/local/functions/ruby.rb', line 15

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



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

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