comparison lib/redmine/custom_field_format.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42 261b3d9a4903
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 2 # Copyright (C) 2006-2012 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.
24 24
25 attr_accessor :name, :order, :label, :edit_as, :class_names 25 attr_accessor :name, :order, :label, :edit_as, :class_names
26 26
27 def initialize(name, options={}) 27 def initialize(name, options={})
28 self.name = name 28 self.name = name
29 self.label = options[:label] 29 self.label = options[:label] || "label_#{name}".to_sym
30 self.order = options[:order] 30 self.order = options[:order] || self.class.available_formats.size
31 self.edit_as = options[:edit_as] || name 31 self.edit_as = options[:edit_as] || name
32 self.class_names = options[:only] 32 self.class_names = options[:only]
33 end 33 end
34 34
35 def format(value) 35 def format(value)
60 def map(&block) 60 def map(&block)
61 yield self 61 yield self
62 end 62 end
63 63
64 # Registers a custom field format 64 # Registers a custom field format
65 def register(custom_field_format, options={}) 65 def register(*args)
66 custom_field_format = args.first
67 unless custom_field_format.is_a?(Redmine::CustomFieldFormat)
68 custom_field_format = Redmine::CustomFieldFormat.new(*args)
69 end
66 @@available[custom_field_format.name] = custom_field_format unless @@available.keys.include?(custom_field_format.name) 70 @@available[custom_field_format.name] = custom_field_format unless @@available.keys.include?(custom_field_format.name)
67 end 71 end
68 72
69 def available_formats 73 def available_formats
70 @@available.keys 74 @@available.keys