Class: AtPay::Button::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/atpay/button/template.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Template

Requires destination and email in addition to this, which should just be strings…



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/atpay/button/template.rb', line 9

def initialize(options)
  @options = {
    :subject => "Email Order Form",
    :title => "Pay",
    :background_color => "#6dbe45",
    :foreground_color => "#ffffff",
    :image => "https://www.atpay.com/wp-content/themes/atpay/images/bttn_cart.png",
    :processor => ENV["ATPAY_PAYMENT_ADDRESS"] || "[email protected]",
    :templates => File.join(File.dirname(__FILE__), "/templates"),
    :analytic_url => nil,
    :wrap => false,
    :wrap_text => "Made for Mobile"
  }.update(options)

  @options[:image] = nil if @options[:image] == ''
end

Instance Method Details

#render(args = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/atpay/button/template.rb', line 26

def render(args={})
  @options.update args

  template.render({
    'url'          => default_mailto,
    'outlook_url'  => outlook_mailto,
    'yahoo_url'    => yahoo_mailto,
    'content'      => amount,
    'dollar'       => amount.match(/\$\d+(?=\.)/).to_s,
    'cents'        => ".#{amount.match(/(?<=\.)[^.]*/).to_s}",
  }.update(string_hash @options))
end