This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Will return a single code and code set if one exists in the code sets that are | |
# passed in. Returns a hash with a key of code and code_set if found, nil otherwise | |
def preferred_code(preferred_code_sets, codes_attribute=:codes, value_set_map=nil) | |
codes_value = send(codes_attribute) | |
preferred_code_sets = value_set_map ? (preferred_code_sets & value_set_map.collect{|cs| cs["set"]}) : preferred_code_sets | |
matching_code_sets = preferred_code_sets & codes_value.keys | |
#if matching_code_sets.present? <= present is only used in rails empty? is the ruby version of present? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//my variables to test | |
var preferred_code_sets = ['set', 'first', 'code', 'a']; | |
var codes_attribute = {'set': 1, 'dos': 3, 'a': 4}; | |
function codes_attribute(){ | |
{'set': 1, 'dos': 3, 'a': 4}; | |
} | |
function preferred_code(preferred_code_sets, codes_attribute, value_set_map=null){ | |
var code_value = function(code_attributes){try { |
NewerOlder