Module: Koudoku

Defined in:
lib/generators/koudoku/views_generator.rb,
lib/koudoku.rb,
lib/koudoku/engine.rb,
lib/koudoku/errors.rb,
lib/koudoku/version.rb,
app/helpers/koudoku/application_helper.rb,
lib/generators/koudoku/install_generator.rb,
app/controllers/koudoku/application_controller.rb,
app/controllers/koudoku/subscriptions_controller.rb

Overview

Defined Under Namespace

Modules: ApplicationHelper, Plan, Subscription Classes: ApplicationController, Engine, Error, InstallGenerator, NilCardToken, SubscriptionsController, ViewsGenerator

Constant Summary collapse

VERSION =
"2.0.0"
@@subscriptions_owned_by =
nil
@@subscriptions_owned_through =
nil
@@stripe_publishable_key =
nil
@@stripe_secret_key =
nil
@@free_trial_length =
nil
@@prorate =
true
@@layout =
nil

Class Method Summary collapse

Class Method Details

.all(callable = Proc.new) ⇒ Object



88
89
90
# File 'lib/koudoku.rb', line 88

def self.all(callable = Proc.new)
  StripeEvent.all(callable)
end

.free_trial?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/koudoku.rb', line 72

def self.free_trial?
  free_trial_length.to_i > 0
end

.instrument(name, object) ⇒ Object



84
85
86
# File 'lib/koudoku.rb', line 84

def self.instrument(name, object)
  StripeEvent.backend.instrument(StripeEvent.namespace.call(name), object)
end

.layoutObject



33
34
35
# File 'lib/koudoku.rb', line 33

def self.layout
  @@layout || 'application'
end

.layout=(layout) ⇒ Object



37
38
39
# File 'lib/koudoku.rb', line 37

def self.layout=(layout)
  @@layout = layout
end

.owner_assignment_symObject

e.g. :user=



63
64
65
# File 'lib/koudoku.rb', line 63

def self.owner_assignment_sym
  :"#{Koudoku.subscriptions_owned_by}="
end

.owner_classObject

e.g. User



68
69
70
# File 'lib/koudoku.rb', line 68

def self.owner_class
  Koudoku.subscriptions_owned_by.to_s.classify.constantize
end

.owner_id_symObject

e.g. :user_id



58
59
60
# File 'lib/koudoku.rb', line 58

def self.owner_id_sym
  :"#{Koudoku.subscriptions_owned_by}_id"
end

.owner_resourceObject

e.g. :users



53
54
55
# File 'lib/koudoku.rb', line 53

def self.owner_resource
  subscriptions_owned_by.to_s.pluralize.to_sym
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Koudoku)

    the object that the method was called on



45
46
47
48
49
50
# File 'lib/koudoku.rb', line 45

def self.setup
  yield self

  # Configure the Stripe gem.
  Stripe.api_key = stripe_secret_key
end

.subscribe(name, callable = Proc.new) ⇒ Object

STRIPE_EVENT section



80
81
82
# File 'lib/koudoku.rb', line 80

def self.subscribe(name, callable = Proc.new)
  StripeEvent.subscribe(name, callable)
end

.subscriptions_owned_through_or_byObject



14
15
16
# File 'lib/koudoku.rb', line 14

def self.subscriptions_owned_through_or_by
  @@subscriptions_owned_through || @@subscriptions_owned_by
end

.webhooks_api_key=(key) ⇒ Object



41
42
43
# File 'lib/koudoku.rb', line 41

def self.webhooks_api_key=(key)
  raise "Koudoku no longer uses an API key to secure webhooks, please delete the line from \"config/initializers/koudoku.rb\""
end