Module: Redmine::FieldFormat

Defined in:
lib/redmine/field_format.rb

Defined Under Namespace

Classes: AttachmentFormat, Base, BoolFormat, DateFormat, EnumerationFormat, FloatFormat, IntFormat, LinkFormat, List, ListFormat, Numeric, RecordList, StringFormat, TextFormat, Unbounded, UserFormat, VersionFormat

Class Method Summary collapse

Class Method Details

.add(name, klass) ⇒ Object



24
25
26
# File 'lib/redmine/field_format.rb', line 24

def self.add(name, klass)
  all[name.to_s] = klass.instance
end

.allObject



32
33
34
# File 'lib/redmine/field_format.rb', line 32

def self.all
  @formats ||= Hash.new(Base.instance)
end

.as_select(class_name = nil) ⇒ Object

Return an array of custom field formats which can be used in select_tag



45
46
47
48
49
50
51
52
53
# File 'lib/redmine/field_format.rb', line 45

def self.as_select(class_name=nil)
  formats = all.values.select do |format|
    format.class.customized_class_names.nil? ||
      format.class.customized_class_names.include?(class_name)
  end
  formats.map do |format|
    [::I18n.t(format.label), format.name]
  end.sort_by(&:first)
end

.available_formatsObject



36
37
38
# File 'lib/redmine/field_format.rb', line 36

def self.available_formats
  all.keys
end

.delete(name) ⇒ Object



28
29
30
# File 'lib/redmine/field_format.rb', line 28

def self.delete(name)
  all.delete(name.to_s)
end

.find(name) ⇒ Object



40
41
42
# File 'lib/redmine/field_format.rb', line 40

def self.find(name)
  all[name.to_s]
end

.formats_for_custom_field_class(klass = nil) ⇒ Object

Returns an array of formats that can be used for a custom field class



56
57
58
59
60
61
# File 'lib/redmine/field_format.rb', line 56

def self.formats_for_custom_field_class(klass=nil)
  all.values.select do |format|
    format.class.customized_class_names.nil? ||
      format.class.customized_class_names.include?(klass.name)
  end
end