Class: Gold::ShopifyPlan
- Inherits:
-
Object
- Object
- Gold::ShopifyPlan
- Defined in:
- app/models/gold/shopify_plan.rb
Overview
Describes a Shopify plan that a shop is tied to. This may change over the lifetime of the shop. While this is a relatively simple wrapper around the plan name string, it provides some nice query methods.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#affiliate? ⇒ Boolean
Returns true if this is a development (non-live) shop.
-
#bad? ⇒ Boolean
The opposite of ‘#good?`.
-
#cancelled? ⇒ Boolean
Returns true if this shop has cancelled their Shopify subscription.
-
#dormant? ⇒ Boolean
Returns true if this shop is currently paused by the merchant.
-
#frozen? ⇒ Boolean
Returns true if this shop has been frozen by Shopify for non-payment.
-
#good? ⇒ Boolean
Returns whether this shop should be allowed to create an account currently.
-
#initialize(plan) ⇒ ShopifyPlan
constructor
A new instance of ShopifyPlan.
-
#paying? ⇒ Boolean
Returns whether this shop is on a paid plan and is in good standing currently.
-
#staff? ⇒ Boolean
Returns true if this is a shop owned by Shopify staff.
- #to_s ⇒ Object
Constructor Details
#initialize(plan) ⇒ ShopifyPlan
Returns a new instance of ShopifyPlan.
6 7 8 |
# File 'app/models/gold/shopify_plan.rb', line 6 def initialize(plan) @plan = plan end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
14 15 16 |
# File 'app/models/gold/shopify_plan.rb', line 14 def ==(other) plan == other.plan end |
#affiliate? ⇒ Boolean
Returns true if this is a development (non-live) shop.
22 23 24 25 |
# File 'app/models/gold/shopify_plan.rb', line 22 def affiliate? plans = %w[affiliate partner_test] plans.include?(plan) end |
#bad? ⇒ Boolean
The opposite of ‘#good?`
64 65 66 |
# File 'app/models/gold/shopify_plan.rb', line 64 def bad? frozen? || cancelled? end |
#cancelled? ⇒ Boolean
Returns true if this shop has cancelled their Shopify subscription.
41 42 43 |
# File 'app/models/gold/shopify_plan.rb', line 41 def cancelled? plan == "cancelled" end |
#dormant? ⇒ Boolean
Returns true if this shop is currently paused by the merchant. Their online store is not accessible in this situation.
47 48 49 |
# File 'app/models/gold/shopify_plan.rb', line 47 def dormant? plan == "dormant" end |
#frozen? ⇒ Boolean
Returns true if this shop has been frozen by Shopify for non-payment.
36 37 38 |
# File 'app/models/gold/shopify_plan.rb', line 36 def frozen? plan == "frozen" end |
#good? ⇒ Boolean
Returns whether this shop should be allowed to create an account currently.
59 60 61 |
# File 'app/models/gold/shopify_plan.rb', line 59 def good? !bad? end |
#paying? ⇒ Boolean
Returns whether this shop is on a paid plan and is in good standing currently. A paying shop is able to accept charges.
53 54 55 |
# File 'app/models/gold/shopify_plan.rb', line 53 def !(affiliate? || staff? || frozen? || cancelled?) end |
#staff? ⇒ Boolean
Returns true if this is a shop owned by Shopify staff. This specifically excludes Shopify Business shops, as we believe those are paid stores that Shopify employees use for their own businesses.
30 31 32 33 |
# File 'app/models/gold/shopify_plan.rb', line 30 def staff? plans = %w[plus_partner_sandbox staff] plans.include?(plan) end |
#to_s ⇒ Object
10 11 12 |
# File 'app/models/gold/shopify_plan.rb', line 10 def to_s plan end |