Module: SubscriptionsHelper
- Defined in:
- /var/apps/qpixel/app/helpers/subscriptions_helper.rb
Instance Method Summary collapse
-
#frequency_choice ⇒ Array(String, Integer)
Generates <select> options for available subscription frequences.
-
#phrase_for(type) ⇒ String
Gets human-readable representation of a given subscription type.
-
#type_choice_for(user) ⇒ Array(String, String)
Generates <select> options for available subscription types for a given user.
Instance Method Details
#frequency_choice ⇒ Array(String, Integer)
Generates <select> options for available subscription frequences
4 5 6 7 8 9 10 11 |
# File '/var/apps/qpixel/app/helpers/subscriptions_helper.rb', line 4 def frequency_choice [ ['Every day', 1], ['Every week', 7], ['Every month', 30], ['Every quarter', 90] ] end |
#phrase_for(type) ⇒ String
Gets human-readable representation of a given subscription type
16 17 18 19 20 21 22 23 24 25 26 27 |
# File '/var/apps/qpixel/app/helpers/subscriptions_helper.rb', line 16 def phrase_for(type) phrase_map = { all: 'all new questions', tag: 'new questions with the tag', user: 'new questions by the user', interesting: 'new questions classed as interesting', category: 'new questions in the category', moderators: 'announcements and newsletters for moderators' } phrase_map[type.to_sym] || 'nothing, apparently. How did you get here, again?' end |
#type_choice_for(user) ⇒ Array(String, String)
Generates <select> options for available subscription types for a given user
32 33 34 35 |
# File '/var/apps/qpixel/app/helpers/subscriptions_helper.rb', line 32 def type_choice_for(user) Subscription.types_accessible_to(user) .map { |type| [phrase_for(type).capitalize, type] } end |