Sha256: 8fde1ca89226f10cf6475aa75dc56f20a299c4b71a630915b99f1282054ca182

Contents?: true

Size: 955 Bytes

Versions: 48

Compression:

Stored size: 955 Bytes

Contents

module Incline::Helpers
  ##
  # A "formatter" that simply collects formatted route data.
  class RouteHashFormatter

    ##
    # Creates a new hash formatter for the route inspector.
    def initialize
      @buffer = []
      @engine = ''
    end

    ##
    # Gets the resulting hash from the route inspector.
    def result
      @buffer
    end

    ##
    # Analyzes the section title to get the current engine name.
    def section_title(title)
      @engine = title.include?(' ') ? title.rpartition(' ')[2] : title
    end

    ##
    # Does nothing for this formatter.
    def header(routes)
      # no need for a header
    end

    ##
    # Does nothing for this formatter.
    def no_routes
      # no need to do anything here either.
    end

    ##
    # Adds the specified routes to the resulting hash.
    def section(routes)
      routes.each do |r|
        @buffer << r.symbolize_keys.merge(engine: @engine)
      end
    end

  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.2.26 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.25 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.24 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.23 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.22 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.21 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.20 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.19 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.18 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.17 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.16 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.15 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.14 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.13 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.12 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.11 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.10 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.9 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.8 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.7 lib/incline/helpers/route_hash_formatter.rb