Module: PaidUp::FeaturesHelper

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

Overview

PaidUp Features Helper

Instance Method Summary collapse

Methods included from PaidUpHelper

#date_range, #paid_up_google_analytics_data_layer

Instance Method Details

#feature_abilities_table(options = {}) ⇒ Object



55
56
57
58
59
60
61
# File 'app/helpers/paid_up/features_helper.rb', line 55

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



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

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

#feature_state(feature) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/paid_up/features_helper.rb', line 29

def feature_state(feature)
  case feature.setting_type
  when 'boolean'
    boolean_state(feature)
  when 'table_rows'
    setting_state feature, current_user.table_setting(feature.slug)
  when 'rolify_rows'
    setting_state feature, current_user.rolify_setting(feature.slug)
  else
    :error.l
  end
end

#features_dl(plan) ⇒ Object



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

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

  features.each do |feature|
    data[feature.title] = feature_display feature, plan
  end

  dl data
end

#features_table(options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/paid_up/features_helper.rb', line 42

def features_table(options = {})
  plans = PaidUp::Plan.display options.delete(:only),
                               options.delete(:except)
  render(
    partial: 'paid_up/features/table',
    locals: {
      highlight_plan: options.delete(:highlight), plans: plans,
      should_add_buttons: options.delete(:should_add_buttons) || true,
      features: PaidUp::Feature.all, html_options: options
    }
  )
end