Module: InheritedTemplates::ActionController::Base

Defined in:
lib/inherited_templates/action_controller/base.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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
# File 'lib/inherited_templates/action_controller/base.rb', line 4

def self.included(base)
  base.class_eval do
    def self.register_default_view_path(path)
      unless view_paths.include? path
        #resource_view_path = ::ActionView::PathSet.type_cast(path.to_s)
        resource_view_path = ::ActionView::PathSet.new(Array.wrap(path.to_s))

        resource_view_path.instance_eval do
          def [](path)
            super(path.to_s.sub(%r[\A[^/]+/], ''))
          end

          def relative_path_for_template_file(full_file_path)
            full_file_path.split("#{@path}/").last
          end

          def templates_dir_from_path(path)
            @path
          end
        end

        append_view_path(resource_view_path)
      end
    end
  end
end