Module: FatFreeCRM::Cloudfuji
- Defined in:
- lib/fat_free_crm/cloudfuji.rb,
lib/ffcrm_cloudfuji/engine.rb,
lib/ffcrm_cloudfuji/version.rb,
lib/fat_free_crm/cloudfuji/view_hooks.rb,
lib/fat_free_crm/cloudfuji/event_observers/base.rb,
lib/fat_free_crm/cloudfuji/event_observers/app_observer.rb,
lib/fat_free_crm/cloudfuji/event_observers/user_observer.rb,
lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb,
lib/fat_free_crm/cloudfuji/event_observers/error_observer.rb,
lib/fat_free_crm/cloudfuji/event_observers/payment_observer.rb,
lib/fat_free_crm/cloudfuji/event_observers/customer_observer.rb,
lib/fat_free_crm/cloudfuji/event_observers/event_rules_observer.rb
Defined Under Namespace
Modules: EventObservers
Classes: CloudfujiViewHooks, Engine
Constant Summary
collapse
- VERSION =
'0.4.1'
Class Method Summary
collapse
Class Method Details
.enable_cloudfuji! ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/fat_free_crm/cloudfuji.rb', line 4
def enable_cloudfuji!
load_observers!
extend_lead!
extend_email!
if (User.table_exists? rescue false)
extend_user!
setup_authentication!
end
end
|
.extend_email! ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/fat_free_crm/cloudfuji.rb', line 48
def extend_email!
Email.class_eval do
def direction
attr_direction = super
return attr_direction if attr_direction.present?
if sent_from.include?(user.email)
'sent'
elsif sent_to.include?(user.email)
'received'
end
end
end
end
|
.extend_lead! ⇒ Object
41
42
43
44
45
46
|
# File 'lib/fat_free_crm/cloudfuji.rb', line 41
def extend_lead!
puts "Extending the Lead model"
Lead.instance_eval do
has_many :lead_event_rule_counts
end
end
|
.extend_user! ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/fat_free_crm/cloudfuji.rb', line 15
def extend_user!
puts "Extending the User model"
User.instance_eval do
include ::Cloudfuji::UserHelper
validates_presence_of :ido_id
validates_uniqueness_of :ido_id
before_create :make_admin
end
User.class_eval do
def make_admin
self.admin = true
end
def ()
self.first_name = ["first_name"]
self.last_name = ["last_name"]
self.locale = ["locale"]
self.email = ["email"]
self.username ||= ["email"].split("@").first
end
end
end
|
.load_observers! ⇒ Object
66
67
68
69
|
# File 'lib/fat_free_crm/cloudfuji.rb', line 66
def load_observers!
require File.expand_path("../cloudfuji/event_observers/base", __FILE__)
Dir[File.expand_path("../cloudfuji/event_observers/*.rb", __FILE__)].each { |file| require file }
end
|
.setup_authentication! ⇒ Object
71
72
73
74
75
|
# File 'lib/fat_free_crm/cloudfuji.rb', line 71
def setup_authentication!
Authlogic::Cas.actor_model = User
Authlogic::Cas.authentication_model = Authentication
Authlogic::Cas.setup_authentication
end
|