Sha256: 25b1325e9d2a1a3b8ea76b2bb6dbd5b34defcc1efaec3c89eb2a6fdbc8b0b337

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

module TaoOnRails
  module ActionView
    module Helpers
      extend ActiveSupport::Concern

      def page_id
        return @page_id if defined?(@page_id)
        controller_names = controller_path.split('/')
        [controller_names, action_name].compact.flatten.join('_').dasherize
      end

      class_methods do
        # Define the dynamic view helpers for components
        # This method should be called in action_view context
        def define_component_helpers
          load_tao_components
          ::ActiveSupport.run_load_hooks(:tao_components, self)

          TaoOnRails::BaseComponent.descendants.each do |klass|
            module_eval %Q{
              def #{klass.tag_name.underscore} *args, &block
                #{klass.name}.new(self, *args).render(&block)
              end
            }
          end
        end

        def load_tao_components(root = Rails.root)
          Dir.glob([
            root.join('lib/**/components/**/*.rb'),
            root.join('app/**/components/**/*.rb')
          ]).each do |component|
            require component
          end
        end

      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tao_on_rails-2.0.0.pre.beta.9 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-2.0.0.pre.beta.8 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-2.0.0.pre.beta.7 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-2.0.0.pre.beta.6 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-2.0.0.pre.beta.5 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-2.0.0.pre.beta.4 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-2.0.0.pre.beta.3 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-2.0.0.pre.beta.2 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-2.0.0.pre.beta.1 lib/tao_on_rails/action_view/helpers.rb