Class: Rack::Utm
- Inherits:
-
Object
- Object
- Rack::Utm
- Defined in:
- lib/rack_utm.rb
Constant Summary collapse
- DEFAULT_REQUIRED_PARAMETERS =
%w[utm_source utm_medium utm_term utm_content utm_campaign].freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, **options) ⇒ Utm
constructor
A new instance of Utm.
Constructor Details
#initialize(app, **options) ⇒ Utm
Returns a new instance of Utm.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rack_utm.rb', line 8 def initialize(app, **) @app = app @required_parameters = .fetch(:required_parameters, DEFAULT_REQUIRED_PARAMETERS).map(&:to_s) @cookie_time_to_live = .fetch(:cookie_time_to_live, ) @allow_overwrite = .fetch(:allow_overwrite, true) @cookie_path = [:cookie_path] @cookie_domain = [:cookie_domain] @optional_parameters = .fetch(:optional_parameters, []).map(&:to_s) end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rack_utm.rb', line 19 def call(env) @req = Rack::Request.new(env) set_env(env) status, headers, body = app.call(env) if (headers) else (headers) end [status, headers, body] end |