class Rooftop::Rails::PostTypeResolver

A class to generate a proper rails route for Rooftop resources.

You can configure a custom route in Rooftop::Rails::Configuration.resource_route_map. If you don't, this class will introspect the Rails routes to try and guess. Otherwise it'll return nothing.

Attributes

type[RW]

Create the route resolver, with a type (post, page, whatever) and an optional ID

Public Class Methods

new(type) click to toggle source
# File lib/rooftop/rails/post_type_resolver.rb, line 10
def initialize(type)
  @type = type.to_sym
end

Public Instance Methods

resolve() click to toggle source
# File lib/rooftop/rails/post_type_resolver.rb, line 14
def resolve()
  begin
    if Rooftop.configuration.post_type_mapping[@type].present?
      Rooftop.configuration.post_type_mapping[@type]
    else
      @type.to_s.classify.constantize
    end
  rescue
    nil
  end
end