Module: Fulcrum::Cloudfuji
- Defined in:
- lib/fulcrum/cloudfuji.rb,
lib/fulcrum_cloudfuji/engine.rb,
lib/fulcrum_cloudfuji/version.rb,
lib/fulcrum/cloudfuji/event_observers/app_observer.rb,
lib/fulcrum/cloudfuji/event_observers/user_observer.rb,
lib/fulcrum/cloudfuji/event_observers/project_observer.rb,
lib/fulcrum/cloudfuji/event_observers/project_task_observer.rb,
lib/fulcrum/cloudfuji/event_observers/project_task_note_observer.rb
Defined Under Namespace
Modules: EventObservers
Classes: Engine
Constant Summary
collapse
- VERSION =
'0.2.2'
Class Method Summary
collapse
Class Method Details
.disable_devise_for_cloudfuji_controllers! ⇒ Object
Temporary hack because all routes require authentication in Fulcrum
78
79
80
81
82
83
84
85
86
|
# File 'lib/fulcrum/cloudfuji.rb', line 78
def disable_devise_for_cloudfuji_controllers!
puts "Disabling devise auth protection on cloudfuji controllers"
::Cloudfuji::DataController.instance_eval { before_filter :authenticate_user!, :except => [:index] }
::Cloudfuji::EnvsController.instance_eval { before_filter :authenticate_user!, :except => [:update] }
::Cloudfuji::MailController.instance_eval { before_filter :authenticate_user!, :except => [:index] }
puts "Devise checks disabled for Cloudfuji controllers"
end
|
.enable_cloudfuji! ⇒ Object
4
5
6
7
8
9
|
# File 'lib/fulcrum/cloudfuji.rb', line 4
def enable_cloudfuji!
load_observers!
extend_user!
extend_project!
disable_devise_for_cloudfuji_controllers!
end
|
.extend_project! ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/fulcrum/cloudfuji.rb', line 53
def extend_project!
puts "Extending the Project model"
Project.class_eval do
after_create :add_all_users!
validates_presence_of :ido_id
validates_uniqueness_of :ido_id
before_validation Proc.new { |p| p.ido_id ||= UUID.new.generate }
def add_all_users!
User.all.each do |user|
unless self.users.include?(user)
self.users << user
end
end
end
end
end
|
.extend_user! ⇒ Object
11
12
13
14
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
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/fulcrum/cloudfuji.rb', line 11
def extend_user!
puts "Extending the User model"
User.class_eval do
validates_presence_of :ido_id
validates_uniqueness_of :ido_id
attr_accessible :ido_id
after_create :add_all_projects!
before_destroy :remove_all_projects!
def set_random_password_if_blank
super unless ::Cloudfuji::Platform.on_cloudfuji?
end
alias :set_reset_password_token :set_random_password_if_blank
def ()
self.name = "#{['first_name'].to_s} #{['last_name'].to_s}"
if ['first_name'] && ['last_name']
self.initials = "#{['first_name'][0].upcase}#{['last_name'][0].upcase}"
else
self.initials = "#{['email'][0].upcase}#{['email'][1].upcase}"
end
self.email = ["email"]
end
def add_all_projects!
Project.all.each { |project| project.users << self unless project.users.member?(self) }
end
def remove_all_projects!
Project.all.each { |project| project.users.delete(self) if project.users.member?(self) }
end
def active_for_authentication?
super && active?
end
end
end
|
.load_observers! ⇒ Object
72
73
74
|
# File 'lib/fulcrum/cloudfuji.rb', line 72
def load_observers!
Dir[File.expand_path("../cloudfuji/event_observers/*.rb", __FILE__)].each { |file| require file }
end
|