Sha256: 3e8b2bdfa893b52ab7464fd20080a9bdb4e594a25e301b67fa369742cd41da20

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 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?
    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, image_identifier = nil)
      function = Blitline::Function.new(function_name, function_params)
      @functions << function
      function.add_save(image_identifier) if image_identifier
    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

1 entries across 1 versions & 1 rubygems

Version Path
blitline-1.0.1 lib/blitline/function.rb