Sha256: 81ded15d9d0f4b7a92c785aba1b30c2962b9cdb214c3adc5bf2f9c3af4e80361

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

module Rtml::Controller::RtmlHelpers
  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

  # This is where the instance of +Rtml::Controller::DocumentGenerator+ is finally instantiated. See
  # that class for more information.
  def rtml_helpers
    @rtml_helpers ||= self.class.rtml_helpers.new(self)
  end

  # 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.
  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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rtml-2.0.4 lib/rtml/controller/rtml_helpers.rb
rtml-2.0.3 lib/rtml/controller/rtml_helpers.rb
rtml-2.0.2 lib/rtml/controller/rtml_helpers.rb
rtml-2.0.1 lib/rtml/controller/rtml_helpers.rb
rtml-2.0.0.alpha.1 lib/rtml/controller/rtml_helpers.rb