Class: Auth::Workflow::Stage

Inherits:
Object
  • Object
show all
Includes:
Concerns::WorkflowConcern
Defined in:
app/models/auth/workflow/stage.rb

Constant Summary collapse

FIELDS_LOCKED_AFTER_ORDER_ADDED =
["applicable"]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assembly_doc_versionObject

Returns the value of attribute assembly_doc_version.



12
13
14
# File 'app/models/auth/workflow/stage.rb', line 12

def assembly_doc_version
  @assembly_doc_version
end

#assembly_idObject

Returns the value of attribute assembly_id.



11
12
13
# File 'app/models/auth/workflow/stage.rb', line 11

def assembly_id
  @assembly_id
end

#stage_indexObject

Returns the value of attribute stage_index.



13
14
15
# File 'app/models/auth/workflow/stage.rb', line 13

def stage_index
  @stage_index
end

Class Method Details

.find_self(id, signed_in_resource, options = {}) ⇒ Object



17
18
19
20
21
# File 'app/models/auth/workflow/stage.rb', line 17

def self.find_self(id,signed_in_resource,options={})
	return nil unless collection =  Auth.configuration.assembly_class.constantize.where("stages._id" => BSON::ObjectId(id)
	)
	collection.first
end

.permitted_paramsObject



23
24
25
# File 'app/models/auth/workflow/stage.rb', line 23

def self.permitted_params
	[{:stage => [:applicable, :name,:description,:assembly_id,:assembly_doc_version,:doc_version,:stage_index]},:id]
end

Instance Method Details

#create_with_conditions(params, permitted_params, model) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/models/auth/workflow/stage.rb', line 28

def create_with_conditions(params,permitted_params,model)
	## in this case the model is a stage model.
	
	return false unless model.valid? 
	
	assembly_updated = Auth.configuration.assembly_class.constantize.where({
		"$and" => [
			{
				:_id => BSON::ObjectId(model.assembly_id)
			},
			{
				:doc_version => model.assembly_doc_version
			},
			{
				"stages.sops.orders" => {
		            "$exists" => false
		        }
			}
		]
	})
	.find_one_and_update(
		{
			"$push" => 
			{
				:stages => model.attributes
			}
		},
		{
			:return_document => :after
		}
	)

	#puts assembly_updated.attributes.to_s
	#puts assembly_updated.stages.to_s

	return false unless assembly_updated
	return model


end