Sha256: 3f5e1be9f6e8c53f226c442848f302e9e2b54570a5fe53d95953bc3679cf677d

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 KB

Contents

begin
  require 'rails/railtie'
rescue LoadError
else
  module Cell
    class Railtie < Rails::Railtie
      require 'cell/rails'
      config.cells = ActiveSupport::OrderedOptions.new

      initializer('cells.attach_router') do |app|
        ViewModel.class_eval do
          include app.routes.url_helpers # TODO: i hate this, make it better in Rails.
        end
      end

      initializer 'cells.template_engine' do |app|
        ViewModel.template_engine = app.config.app_generators.rails.fetch(:template_engine, 'erb').to_s
      end

      # ruthlessly stolen from the zurb-foundation gem.
      initializer 'cells.update_asset_paths' do |app|
        Array(app.config.cells.with_assets).each do |name|
          # FIXME: this doesn't take engine cells into account.
          app.config.assets.paths.append "#{app.root}/app/cells/#{name}/assets"
          app.config.assets.paths.append "#{app.root}/app/concepts/#{name}/assets" # TODO: find out type.
        end
      end

      initializer('cells.rails_extensions') do |app|
        ActiveSupport.on_load(:action_controller) do
          self.class_eval do
            include ::Cell::RailsExtensions::ActionController
          end
        end

        ActiveSupport.on_load(:action_view) do
          self.class_eval do
            include ::Cell::RailsExtensions::ActionView
          end

          #include assert helpers (image_path, font_path, ect)
          ViewModel.class_eval do
            include ActionView::Helpers::AssetTagHelper
          end
        end
      end

      initializer('cells.development') do |app|
        if Rails.env == "development"
          require "cell/development"
          ViewModel.send(:include, Development)
        end
      end

      rake_tasks do
        load 'tasks/cells.rake'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
cells-4.0.0.beta4 lib/cell/railtie.rb
cells-4.0.0.beta3 lib/cell/railtie.rb
cells-4.0.0.beta2 lib/cell/railtie.rb
cells-4.0.0.beta1 lib/cell/railtie.rb
cells-jamie-4.0.0.alpha1 lib/cell/railtie.rb