Class: Distribot::Task
- Inherits:
-
Struct
- Object
- Struct
- Distribot::Task
- Defined in:
- lib/distribot/task.rb
Instance Attribute Summary collapse
-
#depends_on ⇒ Object
Returns the value of attribute depends_on.
-
#handler_data ⇒ Object
Returns the value of attribute handler_data.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
Instance Attribute Details
#depends_on ⇒ Object
Returns the value of attribute depends_on
3 4 5 |
# File 'lib/distribot/task.rb', line 3 def depends_on @depends_on end |
#handler_data ⇒ Object
Returns the value of attribute handler_data
3 4 5 |
# File 'lib/distribot/task.rb', line 3 def handler_data @handler_data end |
#name ⇒ Object
Returns the value of attribute 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 |