forked from chienpeng/match-my-fashion-public-CodeCreators
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJobFunctionality
61 lines (43 loc) · 2.58 KB
/
JobFunctionality
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
Two related database fields for the job aspect
[:job_name] is the string form of the class for that users profession.
Use [:job_name].to_s.constantize to use it. For example [:job_name].to_s.constantize.view_Attr()
[:job_attr] is a hash, where each of the values from [:job_name].to_s.constantize.view_attr is a key, and the
user's input for the job's attributes is a value. Value can be of any data type.
## BEING CHANGED to the key is of the form :0, :1, :2, etc, and will work like an array.
All of the new GeneralInfo class methods.
GeneralInfo.see_Jobs
Outputs an array with the name of every job class currently available.
GeneralInfo.see_Types
Outputs an array of the valid types an attribute can have. Viewable in the
model as @@AcceptableAttrTypes
GeneralInfo.check_Job?(jobName)
Checks if jobName is an existing job.
GeneralInfo.delete_Job(jobName)
Removes a job from the list of available jobs. Does NOT currently rewrite
existing database entries with that job.
GeneralInfo.delete_Job_From_File(job_Name)
GeneralInfo.load_Job_File()
The jobs and their attributes are saved to a file in order to reload them
between server restarts. These functions just write/delete jobs from that
file and and recreates the classes based on what's saved there.
GeneralInfo.create_Job (jobName, writeToFile = true)
Creates a class from string className that has the methods listed below. If writeToFile
is false, it will not write this class to the file mentioned above (In order to prevent
the file from rewriting the its contents to itself whenever it's loaded).
All of the following edit any database entries containing this job to reflect the
correct information
jobName.add_Attr(attr_Name, attr_Type = "String")
Adds an attribute attr_Name to the job of type attr_Type.
jobName.edit_Attr(attr_Name, new_Name, new_Type = nil)
Changes the name of an attribute named attr_Name to new_Name. If new_Type is left set
to nil, the type of the attribute will stay at its current value.
jobName.delete_Attr(attr_Name)
Removes an attribute from the job.
jobName.view_Attr()
Outputs an array of the job's available attributes.
jobName.view_Attr_Type(attr_Name)
Outputs the type of an attribute attr_Name in string form. Returns nil if it doesn't exist.
jobName.view_Attr_Type()
Same as jobName.view_Attr()
jobName.update_File()
Updates the job file to reflect the current state of the job and its attributes.