Sha256: 518012274405b51e470008c57fd94336cd86d5b7f01d324432f2266114f969e0

Contents?: true

Size: 933 Bytes

Versions: 13

Compression:

Stored size: 933 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, headers = {})
      save = Blitline::Save.new(image_identifier)
      if s3_key && s3_bucket
        save.add_s3_destination(s3_key, s3_bucket, headers)
      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

13 entries across 13 versions & 1 rubygems

Version Path
blitline-2.9.0 lib/blitline/function.rb
blitline-2.8.0 lib/blitline/function.rb
blitline-2.7.0 lib/blitline/function.rb
blitline-2.6.0 lib/blitline/function.rb
blitline-2.5.1 lib/blitline/function.rb
blitline-2.5.0 lib/blitline/function.rb
blitline-2.4.0 lib/blitline/function.rb
blitline-2.3.0 lib/blitline/function.rb
blitline-2.2.0 lib/blitline/function.rb
blitline-2.1.0 lib/blitline/function.rb
blitline-2.0.1 lib/blitline/function.rb
blitline-1.4.0 lib/blitline/function.rb
blitline-1.3.0 lib/blitline/function.rb