Sha256: 000fcd1971e560e14f17b29560695dff324970454b2786f21ae7564b34741cc4

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

require 'rails'
require 'e9_rails'
require 'e9_tags'
require 'money'
require 'inherited_resources'
require 'will_paginate'
require 'has_scope'

require 'e9_crm/rails_extensions'

module E9Crm
  autoload :VERSION,            'e9_crm/version'
  autoload :TrackingController, 'e9_crm/tracking_controller'
  autoload :Model,              'e9_crm/model'

  mattr_accessor :cookie_name
  @@cookie_name = '_e9_tc'

  mattr_accessor :query_param
  @@query_param = 'code'

  mattr_accessor :log_level
  @@log_level = :debug

  mattr_accessor :logging
  @@logging = false

  mattr_accessor :user_model
  @@user_model = nil

  mattr_accessor :tracking_controllers
  @@tracking_controllers = []

  def E9Crm.log(message)
    Rails.logger.send(@@log_level, "e9Crm: #{message}") if @@logging
  end

  def E9Crm.init!
    user_model = case @@user_model
    when Class; @@user_model
    when String, Symbol; @@user_model.classify.constantize
    end

    if user_model
      user_model.send(:include, E9Crm::Model)
    end

    E9Crm.tracking_controllers.each do |controller|
      controller.send(:include, E9Crm::TrackingController)
    end
  end

  class Engine < ::Rails::Engine
    config.e9_crm = E9Crm
    config.active_record.observers ||= []
    config.active_record.observers << :deal_observer
    config.to_prepare { E9Crm.init! }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
e9_crm-0.1.7 lib/e9_crm.rb
e9_crm-0.1.6 lib/e9_crm.rb
e9_crm-0.1.5 lib/e9_crm.rb
e9_crm-0.1.4 lib/e9_crm.rb
e9_crm-0.1.1 lib/e9_crm.rb