Module: PaidUp::FeaturesHelper

Includes:
PaidUpHelper
Defined in:
app/helpers/paid_up/features_helper.rb

Instance Method Summary collapse

Methods included from PaidUpHelper

#date_range

Instance Method Details

#feature_abilities_table(options = {}) ⇒ Object



60
61
62
63
# File 'app/helpers/paid_up/features_helper.rb', line 60

def feature_abilities_table(options = {})
  features = PaidUp::Feature.all
  render(partial: 'paid_up/features/abilities_table', locals: { features: features, html_options: options})
end

#feature_display(feature, plan) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/paid_up/features_helper.rb', line 16

def feature_display(feature, plan)
  if feature.setting_type == 'boolean'
    if plan.feature_setting(feature.slug)
      icon 'ok'
    else
      icon 'remove'
    end
  elsif plan.feature_unlimited?(feature.slug)
    :unlimited.l
  else
    plan.feature_setting(feature.slug)
  end
end

#features_dl(plan) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/paid_up/features_helper.rb', line 5

def features_dl(plan)
  data = {}
  features = PaidUp::Feature.all

  for feature in features
    data[feature.title] = feature_display feature, plan
  end

  dl data
end

#features_table(options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/helpers/paid_up/features_helper.rb', line 30

def features_table(options = {})
  features = PaidUp::Feature.all

  if !options[:should_add_buttons].nil?
    should_add_buttons = options[:should_add_buttons]
    options.delete(:should_add_buttons)
  else
    should_add_buttons = true
  end

  plans = PaidUp::Plan.subscribable
  if options[:only].present?
    plans = plans.where('id IN (?)', options[:only])
    options.delete(:only)
  end
  if options[:except].present?
    plans = plans.where('NOT ( id IN (?) )', options[:except])
    options.delete(:except)
  end

  if options[:highlight].present?
    highlight_plan = options[:highlight]
    options.delete(:highlight)
  else
    highlight_plan = nil
  end

  render(partial: 'paid_up/features/table', locals: { should_add_buttons: should_add_buttons, plans: plans, features: features, highlight_plan: highlight_plan, html_options: options})
end