Sha256: 4794da0d3e04440b17fdbe9304ac9f2a10dd6364b58d1e31bb0c3fb0bfa27e22

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

module Burgundy
  module UrlMethods
    def default_url_options
      action_mailer_default_url_options ||
      Rails.application.routes.default_url_options
    end

    def action_mailer_default_url_options
      Rails.configuration.action_mailer.default_url_options if Rails.configuration.respond_to?(:action_mailer)
    end
  end

  module Helpers
    extend ActiveSupport::Concern

    included do
      delegate :translate, :t, :localize, :l, to: :helpers
    end

    def helpers
      ApplicationController.helpers
    end
    alias_method :h, :helpers
  end

  module RouteHelpers
    extend ActiveSupport::Concern

    module ClassMethods
      def routes_module
        @routes_module ||= Module.new do
          include Rails.application.routes.url_helpers
          include UrlMethods
        end
      end

      def routes
        @routes ||= Object.new.extend(routes_module)
      end
    end

    def to_param
      item.to_param
    end

    def eql?(obj)
      obj == self || item.eql?(obj)
    end

    def routes
      self.class.routes
    end
    alias_method :r, :routes
  end

  class Item
    include Helpers
    include RouteHelpers
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
burgundy-0.3.0 lib/burgundy/rails.rb
burgundy-0.2.0 lib/burgundy/rails.rb
burgundy-0.1.0 lib/burgundy/rails.rb
burgundy-0.0.4 lib/burgundy/rails.rb
burgundy-0.0.3 lib/burgundy/rails.rb
burgundy-0.0.1 lib/burgundy/rails.rb