Sha256: b10d197767075c7d5f3e899d09577f63dfce1c5709b373e3759334d7688e89f7

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require "koudoku/engine"
require "generators/koudoku/install_generator"
require "generators/koudoku/views_generator"

module Koudoku

  mattr_accessor :webhooks_api_key
  @@webhooks_api_key = nil
  
  mattr_accessor :subscriptions_owned_by
  @@subscriptions_owned_by = nil
  
  mattr_accessor :stripe_publishable_key
  @@stripe_publishable_key = nil
  
  mattr_accessor :stripe_secret_key
  @@stripe_secret_key = nil
  
  mattr_accessor :free_trial_length
  @@free_trial_length = nil
  
  def self.setup
    yield self
    
    # Configure the Stripe gem.
    Stripe.api_key = stripe_secret_key
  end
  
  # e.g. :users
  def self.owner_resource
    subscriptions_owned_by.to_s.pluralize.to_sym
  end
  
  # e.g. :user_id
  def self.owner_id_sym
    # e.g. :user_id
    (Koudoku.subscriptions_owned_by.to_s + '_id').to_sym
  end
  
  def self.owner_assignment_sym
    # e.g. :user=
    (Koudoku.subscriptions_owned_by.to_s + '=').to_sym
  end

  # e.g. Users
  def self.owner_class
    # e.g. User
    Koudoku.subscriptions_owned_by.to_s.classify.constantize
  end
  
  def self.free_trial?
    free_trial_length.to_i > 0
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
koudoku-0.0.11 lib/koudoku.rb
koudoku-0.0.10 lib/koudoku.rb
koudoku-0.0.9 lib/koudoku.rb