Sha256: 5a1bfe474614767788433a381b5e7056f990e6395e8297cfe5eb6ac3e23b139b

Contents?: true

Size: 691 Bytes

Versions: 13

Compression:

Stored size: 691 Bytes

Contents

module Dossier
  module Formatter
    extend self
    extend ActiveSupport::Inflector
    extend ActionView::Helpers::NumberHelper

    def number_to_currency_from_cents(value)
      number_to_currency(value /= 100.0)
    end

    def url_formatter
      @url_formatter ||= UrlFormatter.new
    end

    delegate :url_for, :link_to, :url_helpers, to: :url_formatter

    class UrlFormatter
      include ActionView::Helpers::UrlHelper

      def _routes
        Rails.application.routes
      end

      # No controller in current context, must be specified when generating routes
      def controller
      end

      def url_helpers
        _routes.url_helpers
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dossier-2.7.1 lib/dossier/formatter.rb
dossier-2.7.0 lib/dossier/formatter.rb
dossier-2.6.0 lib/dossier/formatter.rb
dossier-2.5.2 lib/dossier/formatter.rb
dossier-2.5.1 lib/dossier/formatter.rb
dossier-2.5.0 lib/dossier/formatter.rb
dossier-2.4.0 lib/dossier/formatter.rb
dossier-2.3.0 lib/dossier/formatter.rb
dossier-2.2.0 lib/dossier/formatter.rb
dossier-2.1.1 lib/dossier/formatter.rb
dossier-2.1.0 lib/dossier/formatter.rb
dossier-2.0.1 lib/dossier/formatter.rb
dossier-2.0.0 lib/dossier/formatter.rb