Module: Rtml::Controller::RtmlHelpers

Defined in:
lib/rtml/controller/rtml_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rtml/controller/rtml_helpers.rb', line 2

def self.included(base)
  base.instance_eval do
    extend Rtml::Controller::DocumentGenerator

    hide_action :load_rtml_helpers!, :render_with_rtml_option, :rtml_helpers, :rtml_actions, :rtml_actions=
    before_filter :load_rtml_helpers!
    class_inheritable_array :rtml_actions
    read_inheritable_attribute(:rtml_actions) || write_inheritable_attribute(:rtml_actions, [])

    def rtml_helpers
      return @rtml_helpers if @rtml_helpers

      if superclass.respond_to?(:rtml_helpers)
        @rtml_helpers = generate_rtml_helpers(Class.new(superclass.rtml_helpers))
      else
        @rtml_helpers = generate_rtml_helpers(Class.new)
      end
    end
  end
end

Instance Method Details

#load_rtml_helpers!Object

This method kicks off the sequence that culminates with the instantiation of a Rtml::Controller::DocumentGenerator object. See documentation for that class for more information.



31
32
33
34
35
36
# File 'lib/rtml/controller/rtml_helpers.rb', line 31

def load_rtml_helpers!
  Rtml.configuration.rtml_helper_paths.each do |path|
    path = File.join(Rails.root, path) unless File.exist?(path)
    Dir[File.join(path, "**/*.rb")].each { |fi| require_dependency fi if File.file?(fi) }
  end
end

#rtml_helpersObject

This is where the instance of Rtml::Controller::DocumentGenerator is finally instantiated. See that class for more information.



25
26
27
# File 'lib/rtml/controller/rtml_helpers.rb', line 25

def rtml_helpers
  @rtml_helpers ||= self.class.rtml_helpers.new(self)
end