Sha256: 1f724da03ac9e0ebeac9e3ec7adec923d1b1edb5317677122e9b8931388c4e6b

Contents?: true

Size: 926 Bytes

Versions: 29

Compression:

Stored size: 926 Bytes

Contents

module Deface
  module Search
    module ClassMethods

      # finds all applicable overrides for supplied template
      #
      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

      # finds all overrides that are using a template / parital as there source
      #
      def find_using(virtual_path)
        self.all.map do |key, overrides_by_name|
          overrides_by_name.values.select do |override|
            [:template, :partial].include?(override.source_argument) && override.args[override.source_argument] == virtual_path
          end
        end.flatten
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre vendor/bundle/gems/deface-1.0.1/lib/deface/search.rb
deface-1.0.1 lib/deface/search.rb
deface-1.0.0 lib/deface/search.rb
deface-1.0.0.rc4 lib/deface/search.rb
deface-1.0.0.rc3 lib/deface/search.rb
deface-1.0.0.rc2 lib/deface/search.rb
deface-1.0.0.rc1 lib/deface/search.rb
deface-0.9.1 lib/deface/search.rb
deface-0.9.0 lib/deface/search.rb