aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/lib/fixture_template.rb
blob: 26f6ec2d0c8ff4f7f3bf0c86d421cda9b38b9b99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module ActionView #:nodoc:
  class FixtureTemplate < Template
    class FixturePath < Template::Path
      def initialize(hash = {})
        @hash = {}
        
        hash.each do |k, v|
          @hash[k.sub(/\.\w+$/, '')] = FixtureTemplate.new(v, k.split("/").last, self)
        end
        
        super("fixtures://root")
      end
      
      def find_template(path)
        @hash[path]
      end
    end
    
    def initialize(body, *args)
      @body = body
      super(*args)
    end
    
    def source
      @body
    end
  
  private
  
    def find_full_path(path, load_paths)
      return '/', path
    end
  
  end
end