Class: Tempo::Controllers::Base
- Inherits:
-
Object
- Object
- Tempo::Controllers::Base
- Defined in:
- lib/tempo/controllers/base.rb
Class Method Summary collapse
- .filter_projects_by_title(options, args) ⇒ Object
-
.fuzzy_match(haystack, matches, attribute = "id") ⇒ Object
Takes an array of source strings and filters them down to the ones that match positively against every member of the matches array.
-
.reassemble_the(args, flag = nil) ⇒ Object
Gli default behavior: When args are sent in a command without quotes, they are broken into an array, and the first block is passed to a flag if present.
Class Method Details
.filter_projects_by_title(options, args) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/tempo/controllers/base.rb', line 6 def filter_projects_by_title(, args) if [:exact] match = reassemble_the args match = [match] model_match @projects, match, "title", :exact else model_match @projects, args, "title", :fuzzy end end |
.fuzzy_match(haystack, matches, attribute = "id") ⇒ Object
Takes an array of source strings and filters them down to the ones that match positively against every member of the matches array
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tempo/controllers/base.rb', line 21 def fuzzy_match(haystack, matches, attribute="id") matches = [matches] unless matches.is_a? Array if haystack.is_a? Array fuzzy_array_match( haystack, matches ) elsif haystack.superclass == Model::Base model_match( haystack, matches, attribute ) end end |
.reassemble_the(args, flag = nil) ⇒ Object
Gli default behavior: When args are sent in a command without quotes, they are broken into an array, and the first block is passed to a flag if present.
Here we reassemble the string, and add value stored in a flag in the front. The value is also added back intto the front of the original array
41 42 43 44 45 46 |
# File 'lib/tempo/controllers/base.rb', line 41 def reassemble_the(args, flag=nil) assembled = "" args.unshift flag if flag args.each { |a| assembled += " #{a}" } assembled.strip! end |