Class: CommissionJunction::CjObject
- Inherits:
-
Object
- Object
- CommissionJunction::CjObject
- Defined in:
- lib/commission_junction.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(params) ⇒ CjObject
constructor
A new instance of CjObject.
Constructor Details
#initialize(params) ⇒ CjObject
Returns a new instance of CjObject.
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/commission_junction.rb', line 108 def initialize(params) raise ArgumentError, "params must be a Hash; got #{params.class} instead" unless params.is_a?(Hash) raise ArgumentError, 'Expecting at least one parameter' unless params.size > 0 # Create instance variables and attribute readers on the fly. # Credit: http://listlibrary.net/ruby-talk/2004/03/00sGI1cD params.each do |key, val| raise ArgumentError, "key must be a String; got #{key.class} instead" unless key.is_a?(String) instance_variable_set("@#{key}".intern, val) instance_eval %Q{ class << self ; attr_reader #{key.intern.inspect} ; end } end end |