Sha256: fb510925cfbc0027468a8388213ff11e367a688135e82b4c7ce9f02a2971f942

Contents?: true

Size: 537 Bytes

Versions: 1

Compression:

Stored size: 537 Bytes

Contents

module CheckPath
  module Base
    class << self
      def included(klass)
        _session = session

        paths.each do |path|
          define_method "#{path}?" do |args = nil|
            current_page?(_session.send(path, args))
          end
        end
      end

      private

      def paths
        paths = session.methods.select { |method| method.to_s.include?('_path') }
        paths.map(&:to_s)
      end

      def session
        ActionDispatch::Integration::Session.new(Rails.application)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
check_path-0.1.0 lib/check_path/base.rb