Class: Rack::TradeTracker::Parameters
- Inherits:
-
Object
- Object
- Rack::TradeTracker::Parameters
- Defined in:
- lib/rack/trade_tracker/parameters.rb,
lib/rack/trade_tracker/parameters/paired.rb,
lib/rack/trade_tracker/parameters/delimited.rb
Defined Under Namespace
Constant Summary collapse
- CAMPAIGN_ID_PARAM =
'campaignID'.freeze
- TT_PARAM =
'tt'.freeze
- MISSING_PARAM_VALUE =
''.freeze
- PERMITTED_PARAMS =
%w(campaignID materialID affiliateID reference).freeze
- MissingParametersError =
Class.new(RuntimeError)
Instance Method Summary collapse
-
#initialize(params) ⇒ Parameters
constructor
A new instance of Parameters.
- #to_hash ⇒ Object
Constructor Details
#initialize(params) ⇒ Parameters
Returns a new instance of Parameters.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rack/trade_tracker/parameters.rb', line 17 def initialize(params) @params = params if params.include?(CAMPAIGN_ID_PARAM) extend Paired elsif params.include?(TT_PARAM) extend Delimited else fail MissingParametersError.new("URL must include either '#{CAMPAIGN_ID_PARAM}' or '#{TT_PARAM}' parameter") end end |
Instance Method Details
#to_hash ⇒ Object
28 29 30 31 32 33 |
# File 'lib/rack/trade_tracker/parameters.rb', line 28 def to_hash PERMITTED_PARAMS.each_with_object({}) do |param, result| key = param.underscore.to_sym result[key] = send(key) end.merge(redirect_url: redirect_url) end |