##// END OF EJS Templates
fix typos of source comments at acts_as_event.rb...
Toshi MARUYAMA -
r12784:82de347dfdf0
parent child
Show More
@@ -1,96 +1,96
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module Redmine
18 module Redmine
19 module Acts
19 module Acts
20 module Event
20 module Event
21 def self.included(base)
21 def self.included(base)
22 base.extend ClassMethods
22 base.extend ClassMethods
23 end
23 end
24
24
25 module ClassMethods
25 module ClassMethods
26 def acts_as_event(options = {})
26 def acts_as_event(options = {})
27 return if self.included_modules.include?(Redmine::Acts::Event::InstanceMethods)
27 return if self.included_modules.include?(Redmine::Acts::Event::InstanceMethods)
28 default_options = { :datetime => :created_on,
28 default_options = { :datetime => :created_on,
29 :title => :title,
29 :title => :title,
30 :description => :description,
30 :description => :description,
31 :author => :author,
31 :author => :author,
32 :url => {:controller => 'welcome'},
32 :url => {:controller => 'welcome'},
33 :type => self.name.underscore.dasherize }
33 :type => self.name.underscore.dasherize }
34
34
35 cattr_accessor :event_options
35 cattr_accessor :event_options
36 self.event_options = default_options.merge(options)
36 self.event_options = default_options.merge(options)
37 send :include, Redmine::Acts::Event::InstanceMethods
37 send :include, Redmine::Acts::Event::InstanceMethods
38 end
38 end
39 end
39 end
40
40
41 module InstanceMethods
41 module InstanceMethods
42 def self.included(base)
42 def self.included(base)
43 base.extend ClassMethods
43 base.extend ClassMethods
44 end
44 end
45
45
46 %w(datetime title description author type).each do |attr|
46 %w(datetime title description author type).each do |attr|
47 src = <<-END_SRC
47 src = <<-END_SRC
48 def event_#{attr}
48 def event_#{attr}
49 option = event_options[:#{attr}]
49 option = event_options[:#{attr}]
50 if option.is_a?(Proc)
50 if option.is_a?(Proc)
51 option.call(self)
51 option.call(self)
52 elsif option.is_a?(Symbol)
52 elsif option.is_a?(Symbol)
53 send(option)
53 send(option)
54 else
54 else
55 option
55 option
56 end
56 end
57 end
57 end
58 END_SRC
58 END_SRC
59 class_eval src, __FILE__, __LINE__
59 class_eval src, __FILE__, __LINE__
60 end
60 end
61
61
62 def event_date
62 def event_date
63 event_datetime.to_date
63 event_datetime.to_date
64 end
64 end
65
65
66 def event_group
66 def event_group
67 group = event_options[:group] ? send(event_options[:group]) : self
67 group = event_options[:group] ? send(event_options[:group]) : self
68 group || self
68 group || self
69 end
69 end
70
70
71 def event_url(options = {})
71 def event_url(options = {})
72 option = event_options[:url]
72 option = event_options[:url]
73 if option.is_a?(Proc)
73 if option.is_a?(Proc)
74 option.call(self).merge(options)
74 option.call(self).merge(options)
75 elsif option.is_a?(Hash)
75 elsif option.is_a?(Hash)
76 option.merge(options)
76 option.merge(options)
77 elsif option.is_a?(Symbol)
77 elsif option.is_a?(Symbol)
78 send(option).merge(options)
78 send(option).merge(options)
79 else
79 else
80 option
80 option
81 end
81 end
82 end
82 end
83
83
84 # Returns the mail adresses of users that should be notified
84 # Returns the mail addresses of users that should be notified
85 def recipients
85 def recipients
86 notified = project.notified_users
86 notified = project.notified_users
87 notified.reject! {|user| !visible?(user)}
87 notified.reject! {|user| !visible?(user)}
88 notified.collect(&:mail)
88 notified.collect(&:mail)
89 end
89 end
90
90
91 module ClassMethods
91 module ClassMethods
92 end
92 end
93 end
93 end
94 end
94 end
95 end
95 end
96 end
96 end
General Comments 0
You need to be logged in to leave comments. Login now