Class: Distribot::Task

Inherits:
Struct
  • Object
show all
Defined in:
lib/distribot/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#depends_onObject

Returns the value of attribute depends_on

Returns:

  • (Object)

    the current value of depends_on



3
4
5
# File 'lib/distribot/task.rb', line 3

def depends_on
  @depends_on
end

#handler_dataObject

Returns the value of attribute handler_data

Returns:

  • (Object)

    the current value of handler_data



3
4
5
# File 'lib/distribot/task.rb', line 3

def handler_data
  @handler_data
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/distribot/task.rb', line 3

def name
  @name
end

Instance Method Details

#handler(handler) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/distribot/task.rb', line 4

def handler(handler)
  case handler.class.to_s
  when 'String', 'Class'
    self.handler_data = {
      name: handler
    }
  when 'Hash'
    handler[:version] ||= nil
    unless handler.keys.sort == [:name, :version]
      raise TaskConfigError.new 'task handler must contain :name and :version'
    end
    self.handler_data = {
      name: handler[:name],
      version: handler[:version]
    }.reject{ |_key,value| value.nil? }
  else
    raise TaskConfigError.new 'task handler must be a String or Hash, not a %s' % handler.class.to_s
  end
end