Class: PaidUp::Plan
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PaidUp::Plan
- Defined in:
- app/models/paid_up/plan.rb
Instance Attribute Summary collapse
-
#stripe_data ⇒ Object
Returns the value of attribute stripe_data.
Instance Method Summary collapse
- #amount ⇒ Object
- #charge ⇒ Object
- #currency ⇒ Object
- #feature_setting(feature_name) ⇒ Object
- #feature_unlimited?(feature_name) ⇒ Boolean
- #interval ⇒ Object
- #interval_count ⇒ Object
- #money ⇒ Object
- #reload(*args, &blk) ⇒ Object
Instance Attribute Details
#stripe_data ⇒ Object
Returns the value of attribute stripe_data.
8 9 10 |
# File 'app/models/paid_up/plan.rb', line 8 def stripe_data @stripe_data end |
Instance Method Details
#amount ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/models/paid_up/plan.rb', line 63 def amount if stripe_data.present? stripe_data.amount else 0 end end |
#charge ⇒ Object
75 76 77 |
# File 'app/models/paid_up/plan.rb', line 75 def charge money.amount end |
#currency ⇒ Object
79 80 81 82 83 84 85 |
# File 'app/models/paid_up/plan.rb', line 79 def currency if stripe_data.present? stripe_data.currency.upcase else :default_currency.l.upcase end end |
#feature_setting(feature_name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/paid_up/plan.rb', line 22 def feature_setting(feature_name) feature = PaidUp::Feature.find_by_slug(feature_name) || raise(:feature_not_found.l) raw = plan_feature_settings.where(feature: feature_name) case feature.setting_type when 'boolean' if raw.empty? false else raw.first.setting != 0 end when 'table_rows', 'rolify_rows' if raw.empty? 0 else raw.first.setting end else raise :error_handling_feature_setting.l feature: feature end end |
#feature_unlimited?(feature_name) ⇒ Boolean
43 44 45 |
# File 'app/models/paid_up/plan.rb', line 43 def feature_unlimited?(feature_name) feature_setting(feature_name) == PaidUp::Unlimited.to_i end |
#interval ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/models/paid_up/plan.rb', line 47 def interval if stripe_data.present? stripe_data.interval else :default_interval.l end end |
#interval_count ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/models/paid_up/plan.rb', line 55 def interval_count if stripe_data.present? stripe_data.interval_count else 1 end end |
#money ⇒ Object
71 72 73 |
# File 'app/models/paid_up/plan.rb', line 71 def money Money.new(amount, currency) end |
#reload(*args, &blk) ⇒ Object
16 17 18 19 20 |
# File 'app/models/paid_up/plan.rb', line 16 def reload(*args, &blk) super *args, &blk load_stripe_data self end |