mirror of https://github.com/docusealco/docuseal
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							18 lines
						
					
					
						
							506 B
						
					
					
				
			
		
		
	
	
							18 lines
						
					
					
						
							506 B
						
					
					
				| # frozen_string_literal: true
 | |
| 
 | |
| module TemplateFolders
 | |
|   module_function
 | |
| 
 | |
|   def search(folders, keyword)
 | |
|     return folders if keyword.blank?
 | |
| 
 | |
|     folders.where(TemplateFolder.arel_table[:name].lower.matches("%#{keyword.downcase}%"))
 | |
|   end
 | |
| 
 | |
|   def find_or_create_by_name(author, name)
 | |
|     return author.account.default_template_folder if name.blank? || name == TemplateFolder::DEFAULT_NAME
 | |
| 
 | |
|     author.account.template_folders.create_with(author:, account: author.account).find_or_create_by(name:)
 | |
|   end
 | |
| end
 |