Module: Deface::Search::ClassMethods

Included in:
Override
Defined in:
lib/deface/search.rb

Instance Method Summary collapse

Instance Method Details

#find(details) ⇒ Object

finds all applicable overrides for supplied template



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/deface/search.rb', line 7

def find(details)
  return [] if self.all.empty? || details.empty?

  virtual_path = details[:virtual_path]
  return [] if virtual_path.nil?

  [/^\//, /\.\w+\z/].each { |regex| virtual_path.gsub!(regex, '') }

  result = []
  result << self.all[virtual_path.to_sym].try(:values)

  result.flatten.compact.sort_by &:sequence
end