Sha256: bdd6a5607e62f707973c2df11a870cc99f3067e119f757456052f633960525a3

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

if defined?(Rails)
  module Voom
    module Presenters
      module Helpers
        module Rails
          include ActionView::Helpers::AssetUrlHelper
          include Voom::Presenters::Helpers::Rails::Currency
          include Voom::Presenters::Helpers::Rails::ModelTable
          include Namespace

          def default_url_options
            {}
          end

          def presenters_path(presenter, host: false, **params)
            presenter = _expand_namespace_(presenter, namespace)
            presenter = presenter.gsub(':', '/')

            path = host ? voom_presenters_web_client_app_url(params, host: router.base_url) :
                          voom_presenters_web_client_app_path(params)

            if path.include?('?')
              path = path.sub('?', "#{presenter}?")
            else
              path = "#{path}/" unless path.end_with?('/')
              # replace last / with the presenter
              path = path.reverse.sub('/', "/#{presenter}".reverse).reverse
            end
            path
          end

          alias presenter_path presenters_path

          def presenters_url(presenter, host: true, **params)
            presenters_path(presenter, host: host, **params)
          end

          alias presenter_url presenters_url
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voom-presenters-2.1.2 lib/voom/presenters/helpers/rails.rb
voom-presenters-2.1.0 lib/voom/presenters/helpers/rails.rb
voom-presenters-2.0.3 lib/voom/presenters/helpers/rails.rb
voom-presenters-2.0.2 lib/voom/presenters/helpers/rails.rb
voom-presenters-2.0.1 lib/voom/presenters/helpers/rails.rb
voom-presenters-2.0.0 lib/voom/presenters/helpers/rails.rb