Sha256: 08af5a94aca26245847de47bb28633524d5f358adb5a850c5a9f3fcc14965369

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module ExceptionHandler
	module ApplicationHelper

		#Refs
		#http://stackoverflow.com/a/5795683/1143732
		#http://stackoverflow.com/questions/8028021/helpers-in-rails-engine
		#ActiveSupport.on_load( :action_view ){ include ExceptionHandler::ViewHelpers }

		#Social
		def social *services
			output = []
			# options = args.extract_options! http://simonecarletti.com/blog/2009/09/inside-ruby-on-rails-extract_options-from-arrays/ - args for hash

			services = ExceptionHandler.config.social unless services.any? #-> http://api.rubyonrails.org/classes/Hash.html#method-i-compact
			services.except(:url).compact.each do |service,username| #-> except http://stackoverflow.com/a/11105831/1143732
    			output.push link_to(image_tag("exception_handler/connect/#{service}.png", title: "Find us on " + service.to_s.titleize), link(service), target: :blank, class: service.to_s)
    		end

    		output.join("").html_safe #-> ruby returns last line
		end

		private

		def link service #-> bloated way to allow single references in config
			url = []
			url.push ExceptionHandler.config.social[:url][service]
			url.push ExceptionHandler.config.social[service]
			url.join("/")
		end

	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exception_handler-0.4.7 app/helpers/exception_handler/application_helper.rb