class Rack::SmartAppBanner
Constants
- VERSION
Public Class Methods
new(app, options = {})
click to toggle source
# File lib/rack/smart-app-banner.rb, line 9 def initialize(app, options = {}) raise ArgumentError, 'App ID Required' unless options[:app_id] && !options[:app_id].empty? raise ArgumentError, 'Incomplete Affiliate Information' if (options[:affiliate_partner_id] || options[:affiliate_site_id]) && !(options[:affiliate_partner_id] && options[:affiliate_site_id]) raise ArgumentError, 'App Argument Must Be Lambda' if options[:app_argument] && !options[:app_argument].lambda? @app = app @options = options end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/smart-app-banner.rb, line 19 def call(env) @status, @headers, @response = @app.call(env) return [@status, @headers, @response] unless html? request = Rack::Request.new(env) response = Rack::Response.new([], @status, @headers) if @response.respond_to?(:to_ary) @response.each do |fragment| response.write inject_smart_app_banner(request, fragment) end end response.finish end
Private Instance Methods
html?()
click to toggle source
# File lib/rack/smart-app-banner.rb, line 36 def html? @headers['Content-Type'] =~ /html/ end