Class: PaddleConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-paddle/paddle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, options) ⇒ PaddleConfig

Returns a new instance of PaddleConfig.



10
11
12
13
# File 'lib/motion-paddle/paddle.rb', line 10

def initialize(config, options)
  @config = config
  @options = options
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def api_key
  @api_key
end

#currencyObject

Returns the value of attribute currency.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def currency
  @currency
end

#current_priceObject

Returns the value of attribute current_price.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def current_price
  @current_price
end

#dev_nameObject

Returns the value of attribute dev_name.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def dev_name
  @dev_name
end

#imageObject

Returns the value of attribute image.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def image
  @image
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/motion-paddle/paddle.rb', line 6

def options
  @options
end

#product_idObject

Returns the value of attribute product_id.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def product_id
  @product_id
end

#product_imageObject

Returns the value of attribute product_image.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def product_image
  @product_image
end

#product_nameObject

Returns the value of attribute product_name.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def product_name
  @product_name
end

#storeObject

Returns the value of attribute store.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def store
  @store
end

#time_trialObject

Returns the value of attribute time_trial.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def time_trial
  @time_trial
end

#trial_durationObject

Returns the value of attribute trial_duration.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def trial_duration
  @trial_duration
end

#trial_textObject

Returns the value of attribute trial_text.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def trial_text
  @trial_text
end

#vendor_idObject

Returns the value of attribute vendor_id.



7
8
9
# File 'lib/motion-paddle/paddle.rb', line 7

def vendor_id
  @vendor_id
end

Instance Method Details

#inspectObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/motion-paddle/paddle.rb', line 29

def inspect
  {
      product_id: product_id,
      vendor_id: vendor_id,
      api_key: api_key,
      current_price: current_price,
      dev_name: dev_name,
      currency: currency,
      image: image,
      product_name: product_name,
      trial_duration: trial_duration,
      trial_text: trial_text,
      product_image: product_image,
      time_trial: time_trial,
      store: store
  }.inspect
end

#mas_store?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/motion-paddle/paddle.rb', line 15

def mas_store?
  @options[:force_mas] || ENV.fetch('store', 'paddle').downcase == 'mas'
end

#paddle_store?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/motion-paddle/paddle.rb', line 19

def paddle_store?
  !@options[:force_mas] && ENV.fetch('store', 'paddle').downcase == 'paddle'
end

#set(var, val) ⇒ Object



23
24
25
26
27
# File 'lib/motion-paddle/paddle.rb', line 23

def set(var, val)
  @config.info_plist["MotionPaddle_#{@config.short_version}"] ||= [{}]
  @config.info_plist["MotionPaddle_#{@config.short_version}"].first[var.to_s] = val
  send("#{var}=", val)
end