Sha256: d939e4aa8e0e5ea8d99dd2b6f1ba885747e4601aae0be2b621d3a0d3a2275566
Contents?: true
Size: 1.07 KB
Versions: 7
Compression:
Stored size: 1.07 KB
Contents
require "social_avatar_proxy/app" require "social_avatar_proxy/path_helpers" module SocialAvatarProxy class Engine < ::Rails::Engine endpoint App def self.mounted_at @mounted_at ||= calculate_mounted_at end def self.calculate_mounted_at route ||= Rails.application.routes.routes.detect do |route| route.app == self end # if it's not found, it's not mounted unless route raise "#{self} is not yet mounted." end # return the route with it's slashes stripped route.path.spec.to_s.gsub(/^\/|\/$/, "") end module Helpers def self.included(base) base.helper_method :twitter_avatar_path base.helper_method :facebook_avatar_path end def twitter_avatar_path(identifier) "/#{SocialAvatarProxy::Engine.mounted_at}/twitter/#{identifier}" end def facebook_avatar_path(identifier) "/#{SocialAvatarProxy::Engine.mounted_at}/facebook/#{identifier}" end end ActionController::Base.send(:include, Helpers) end end
Version data entries
7 entries across 7 versions & 1 rubygems