Module: Mutx::API::CustomParams
- Defined in:
- lib/mutx/API/custom_params.rb
Class Method Summary collapse
- .get(custom_param_name) ⇒ Object
-
.list ⇒ Object
DATABASE COLLECTION ACTIONS.
- .sanitize(data) ⇒ Object
- .set(data) ⇒ Object
Class Method Details
.get(custom_param_name) ⇒ Object
24 25 26 27 28 |
# File 'lib/mutx/API/custom_params.rb', line 24 def self.get custom_param_name custom_param_name.gsub!("%20"," ") param = Mutx::Database::MongoConnector.custom_param_for_name custom_param_name param || {} end |
.list ⇒ Object
DATABASE COLLECTION ACTIONS
32 33 34 |
# File 'lib/mutx/API/custom_params.rb', line 32 def self.list Mutx::Database::MongoConnector.custom_params_list end |
.sanitize(data) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mutx/API/custom_params.rb', line 36 def self.sanitize data if data["type"] case data["type"].downcase when /select/ data["options"] = data["options"].split(",").uniq.sort data["options"].unshift "none" unless data["required"] data.delete("value") when /text/ data.delete("options") when /json/ data.delete("options") Mutx::Support::Log.debug "custom_param: value for json#{data["value"]}" end data["required"] = data["required"]=="on" end #data["_id"] = data["_id"].to_i if data.keys.include? "_id" # MD5 dont need to be coverted to int data end |
.set(data) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mutx/API/custom_params.rb', line 7 def self.set data # Sanity data = self.sanitize data response = case data["action"] when "new" Mutx::Tasks::Custom::Param.validate_and_create(data) when "edit" Mutx::Tasks::Custom::Param.validate_and_update(data) when "delete" Mutx::Tasks::Custom::Param.delete_this(data) end response end |