Class: Toaster::TaskParameter
Constant Summary
collapse
- @@id_attributes =
["task_id", "key", "value", "type"]
Class Method Summary
collapse
Instance Method Summary
collapse
from_hash, get_as_hash, #to_s
Constructor Details
Returns a new instance of TaskParameter.
14
15
16
17
18
19
|
# File 'lib/toaster/model/task_parameter.rb', line 14
def initialize(attr_hash)
if !attr_hash[:uuid]
attr_hash[:uuid] = Util.generate_short_uid()
end
super(attr_hash)
end
|
Class Method Details
.find(criteria = {}, preset_fields = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/toaster/model/task_parameter.rb', line 21
def self.find(criteria={}, preset_fields={})
criteria["db_type"] = "task_parameter" if !criteria["db_type"]
objs = []
DB.instance.find(criteria).each do |hash|
task = preset_fields.include?("task") ? preset_fields["task"] :
Task.load(run_hash["task_id"])
obj = TaskParameter.new(task, nil)
objs << DB.apply_values(obj, hash)
end
return objs
end
|
.load(uuid_or_task, key = nil, value = nil, type = nil, constraints = []) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/toaster/model/task_parameter.rb', line 33
def self.load(uuid_or_task, key = nil, value = nil, type = nil, constraints = [])
param = TaskParameter.new(nil, nil)
hash = {}
if !uuid_or_task.kind_of?(Task)
uuid = uuid_or_task
return nil if !uuid
criteria = {"uuid" => uuid, "db_type" => "task_parameter"}
hash = DB.instance.find_one(criteria)
else
task = uuid_or_task
param = TaskParameter.new(task, key, value, type, constraints)
hash = DB.instance.get_or_insert(param.to_hash(), @@id_attributes)
end
param = DB.apply_values(param, hash)
return param
end
|
Instance Method Details
#eql?(obj) ⇒ Boolean
58
59
60
61
|
# File 'lib/toaster/model/task_parameter.rb', line 58
def eql?(obj)
return obj.kind_of?(TaskParameter) && obj.key == @key && obj.value == @value &&
obj.type == @type && obj.constraints == @constraints
end
|
#hash ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/toaster/model/task_parameter.rb', line 50
def hash
h = @key.hash
h += @value.hash if @value
h += @type.hash if @type
h += @constraints.hash if @constraints
return h
end
|