Module: PaidUp::PlansHelper

Includes:
ActionView::Helpers::NumberHelper
Defined in:
app/helpers/paid_up/plans_helper.rb

Overview

PaidUp Plans Helper

Instance Method Summary collapse

Instance Method Details

#plan_button(plan, text = nil, html_options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/paid_up/plans_helper.rb', line 20

def plan_button(plan, text = nil, html_options = {})
  atts = plan_button_atts(plan)
  atts[:text] = text if text.present?
  atts[:link] ||= paid_up.new_plan_subscription_path(plan)

  html_options[:method] ||= :get
  html_options[:data] = atts.delete(:data)

  icon_button_to(
    atts[:css_class], atts[:icon_class], atts[:text], atts[:link],
    html_options
  )
end

#plan_charge_human(plan, discount) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/paid_up/plans_helper.rb', line 8

def plan_charge_human(plan, discount)
  interval = plan_period_phrase(plan)
  if plan.adjust?(discount)
    return amount_per_interval(plan.money.format, interval)
  end
  plan_charge_reduced(
    plan.money.format,
    plan.adjusted_money(discount).format,
    interval
  )
end

#plan_period_phrase(plan) ⇒ Object



34
35
36
37
38
39
40
41
# File 'app/helpers/paid_up/plans_helper.rb', line 34

def plan_period_phrase(plan)
  period_phrase = ''
  if plan.interval_count > 1
    period_phrase += plan.interval_count.to_s
    period_phrase += ' '
  end
  period_phrase + plan.interval.capitalize
end