Class: SubscriptionPlan

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Payola::Plan
Defined in:
app/models/subscription_plan.rb

Constant Summary collapse

PLANS =
[
  {
    amount: 4999,
    interval: 'month',
    stripe_id: '1',
    name: 'Bronze Monthly',
    repo_count: 2
  },
  {
    amount: 12999,
    interval: 'month',
    stripe_id: '2',
    name: 'Silver Monthly',
    repo_count: 6
  },
  {
    amount: 24999,
    interval: 'month',
    stripe_id: '3',
    name: 'Gold Monthly',
    repo_count: 15
  },
  {
    amount: 54999,
    interval: 'year',
    stripe_id: '4',
    name: 'Bronze Yearly',
    repo_count: 2
  },
  {
    amount: 142999,
    interval: 'year',
    stripe_id: '5',
    name: 'Silver Yearly',
    repo_count: 6
  },
  {
    amount: 274989,
    interval: 'year',
    stripe_id: '6',
    name: 'Gold Yearly',
    repo_count: 15
  },
  {
    amount: 2500,
    interval: 'month',
    stripe_id: '7',
    name: 'Startup Monthly',
    repo_count: 1
  },
  {
    amount: 27500,
    interval: 'year',
    stripe_id: '8',
    name: 'Startup Yearly',
    repo_count: 1
  },
  {
    amount: 0,
    interval: 'year',
    stripe_id: '9',
    name: 'Educational',
    repo_count: 15,
    hidden: true
  }
]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.setup_plansObject



74
75
76
77
78
# File 'app/models/subscription_plan.rb', line 74

def self.setup_plans
  PLANS.each do |plan|
    self.find_or_create_by(plan)
  end
end

Instance Method Details

#plan_hashObject



92
93
94
# File 'app/models/subscription_plan.rb', line 92

def plan_hash
  PLANS.find{|p| p[:stripe_id] == self.stripe_id }
end

#redirect_path(subscription) ⇒ Object



96
97
98
# File 'app/models/subscription_plan.rb', line 96

def redirect_path(subscription)
  '/repositories'
end

#repo_countObject



88
89
90
# File 'app/models/subscription_plan.rb', line 88

def repo_count
  plan_hash[:repo_count]
end

#short_nameObject



84
85
86
# File 'app/models/subscription_plan.rb', line 84

def short_name
  name.gsub(/yearly|monthly/i, '').strip
end

#to_sObject



80
81
82
# File 'app/models/subscription_plan.rb', line 80

def to_s
  name
end