Class: Toaster::TaskParameter
- Inherits:
-
KeyValuePair
- Object
- ActiveRecord::Base
- KeyValuePair
- Toaster::TaskParameter
- Defined in:
- lib/toaster/model/task_parameter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(obj) ⇒ Boolean
-
#hash ⇒ Object
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, “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.
Methods inherited from KeyValuePair
flat_attributes_from_hash, from_hash, get_as_hash, #initialize, #to_s
Constructor Details
This class inherits a constructor from Toaster::KeyValuePair
Class Method Details
.find(criteria = {}, preset_fields = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/toaster/model/task_parameter.rb', line 14 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 |
Instance Method Details
#eql?(obj) ⇒ Boolean
51 52 53 54 |
# File 'lib/toaster/model/task_parameter.rb', line 51 def eql?(obj) return obj.kind_of?(TaskParameter) && obj.key == @key && obj.value == @value && obj.type == @type && obj.constraints == @constraints end |
#hash ⇒ Object
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
43 44 45 46 47 48 49 |
# File 'lib/toaster/model/task_parameter.rb', line 43 def hash h = @key.hash h += @value.hash if @value h += @type.hash if @type h += @constraints.hash if @constraints return h end |