Class: Gold::ShopifyPlan

Inherits:
Object
  • Object
show all
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

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.

Returns:

  • (Boolean)


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?`

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


53
54
55
# File 'app/models/gold/shopify_plan.rb', line 53

def paying?
  !(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.

Returns:

  • (Boolean)


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_sObject



10
11
12
# File 'app/models/gold/shopify_plan.rb', line 10

def to_s
  plan
end