Sha256: 345aa5e4097cedf500fbc63c826a57037dfa09859530bcb70d47fbe2d8563f8c

Contents?: true

Size: 488 Bytes

Versions: 1

Compression:

Stored size: 488 Bytes

Contents

module InferredCrumpets
  class RouteChecker
    def initialize(view_context)
      @view_context = view_context
    end

    def linkable?(subject)
      @view_context.url_for(subject) && true
    rescue NoMethodError
      false
    end

    def can_route?(subject, action, params = {})
      @view_context.url_for({
        action:     action,
        controller: subject.class.table_name,
      }.merge(params))
    rescue ActionController::RoutingError
      false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inferred_crumpets-0.2.4 lib/inferred_crumpets/route_checker.rb