Sha256: 2173573aa20fe047cc9020f22e1ebc2a486d7700d5fee8923686a3e0d3962c6d

Contents?: true

Size: 1009 Bytes

Versions: 59

Compression:

Stored size: 1009 Bytes

Contents

module FaaStRuby
  class Function < BaseObject
    attr_accessor :name, :workspace, :errors, :context, :updated_at, :created_at

    def run(options)
      options['method'] ||= 'get'
      options['headers'] ||= {}
      response = @api.run(function_name: name, workspace_name: options['workspace_name'], payload: options['body'], method: options['method'], headers: options['headers'], time: options['time'], query: options['query'])
      response
    end

    def destroy
      response = @api.delete_from_workspace(function_name: self.name, workspace_name: @workspace.name)
      @errors += response.errors if response.errors.any?
    end

    def update(new_context:)
      payload = {'context' => new_context}
      response = @api.update_function_context(function_name: self.name, workspace_name: @workspace.name, payload: payload)
      @errors += response.errors if response.errors.any?
      unless @errors.any?
        self.context = response.body['context']
      end
      self
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
faastruby-0.4.7 lib/faastruby/function.rb
faastruby-0.4.6 lib/faastruby/function.rb
faastruby-0.4.5 lib/faastruby/function.rb
faastruby-0.4.4 lib/faastruby/function.rb
faastruby-0.4.3 lib/faastruby/function.rb
faastruby-0.4.2 lib/faastruby/function.rb
faastruby-0.4.1 lib/faastruby/function.rb
faastruby-0.4.0 lib/faastruby/function.rb
faastruby-0.3.8 lib/faastruby/function.rb
faastruby-0.3.7 lib/faastruby/function.rb
faastruby-0.3.6 lib/faastruby/function.rb
faastruby-0.3.5 lib/faastruby/function.rb
faastruby-0.3.4 lib/faastruby/function.rb
faastruby-0.3.3 lib/faastruby/function.rb
faastruby-0.3.2 lib/faastruby/function.rb
faastruby-0.3.1 lib/faastruby/function.rb
faastruby-0.2.6 lib/faastruby/function.rb
faastruby-0.2.5 lib/faastruby/function.rb
faastruby-0.2.3 lib/faastruby/function.rb