Sha256: e96854312a4b6c39bbaf518e2d91b942572e7e1f1e5653a9ef17c86427c52a9f

Contents?: true

Size: 747 Bytes

Versions: 21

Compression:

Stored size: 747 Bytes

Contents

class TaskDefinition
  NotFound = Class.new(StandardError)

  class << self
    def load(payload)
      return unless payload.present?
      json = JSON.parse(payload)
      new(json.delete('id'), json)
    end

    def dump(definition)
      return unless definition.present?
      JSON.dump(definition.as_json)
    end
  end

  attr_reader :id, :action, :description, :steps, :checklist

  def initialize(id, config)
    @id = id
    @action = config['action']
    @description = config['description'] || ''
    @steps = config['steps'] || []
    @checklist = config['checklist'] || []
  end

  def as_json
    {
      id: id,
      action: action,
      description: description,
      steps: steps,
      checklist: checklist,
    }
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
shipit-engine-0.5.2 app/models/task_definition.rb
shipit-engine-0.5.1 app/models/task_definition.rb
shipit-engine-0.5.0 app/models/task_definition.rb
shipit-engine-0.4.10 app/models/task_definition.rb
shipit-engine-0.4.9 app/models/task_definition.rb
shipit-engine-0.4.8 app/models/task_definition.rb
shipit-engine-0.4.7 app/models/task_definition.rb
shipit-engine-0.4.6 app/models/task_definition.rb
shipit-engine-0.4.5 app/models/task_definition.rb
shipit-engine-0.4.4 app/models/task_definition.rb
shipit-engine-0.4.3 app/models/task_definition.rb
shipit-engine-0.4.2 app/models/task_definition.rb
shipit-engine-0.4.1 app/models/task_definition.rb
shipit-engine-0.4.0 app/models/task_definition.rb
shipit-engine-0.3.1 app/models/task_definition.rb
shipit-engine-0.3.0 app/models/task_definition.rb
shipit-engine-0.2.3 app/models/task_definition.rb
shipit-engine-0.2.2 app/models/task_definition.rb
shipit-engine-0.2.1 app/models/task_definition.rb
shipit-engine-0.2.0 app/models/task_definition.rb