Sha256: e143188cad2b6102e2f680784534df03268873964bd29e1a5b9feb6cf0d41931

Contents?: true

Size: 598 Bytes

Versions: 4

Compression:

Stored size: 598 Bytes

Contents

# frozen_string_literal: true

module Loco
  module Helpers
    def loco_body_data
      data_controller = controller_name.split('_').map(&:capitalize).join ''
      {
        'data-namespace' => namespace_name,
        'data-controller' => data_controller,
        'data-action' => action_name,
        'data-rails-env' => Rails.env,
        'data-user-agent' => request.user_agent
      }
    end

    private

      def namespace_name
        path = controller_path.split '/'
        if path.size > 1
          path.first
        else
          'Main'
        end.capitalize
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
loco-rails-3.0.4 lib/loco/helpers.rb
loco-rails-3.0.3 lib/loco/helpers.rb
loco-rails-3.0.2 lib/loco/helpers.rb
loco-rails-3.0.1 lib/loco/helpers.rb