Sha256: 4be6e2cf90330fd9e86923f57a5555f13172588153ba8470fbe24ac1b7da0d58

Contents?: true

Size: 910 Bytes

Versions: 2

Compression:

Stored size: 910 Bytes

Contents

class Blitline
  class Function
    include AttributeJsonizer
    attr_accessor :name, :params, :save, :functions

    def initialize(name, params = nil)
      @name = name
      @params = params unless params.nil?
      @functions = []
    end

    def add_save(image_identifier, s3_key = nil, s3_bucket = nil)
      save = Blitline::Save.new(image_identifier)
      if s3_key && s3_bucket
        save.add_s3_destination(s3_key, s3_bucket)
      end
      @save = save
    end

    def add_function(function_name, function_params)
      function = Blitline::Function.new(function_name, function_params)
      @functions << function
      return function
    end

    def validate
      raise "Function must have a name" if @name.nil?
      raise "Params must be a hash" if @params && !@params.is_a?(Hash)
      @save.validate if @save
      @functions.each { |f| f.validate } if @functions
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blitline-1.2.3 lib/blitline/function.rb
blitline-1.2.2 lib/blitline/function.rb