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



22
23
24
# File 'lib/redmine/field_format.rb', line 22

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

.allObject



30
31
32
# File 'lib/redmine/field_format.rb', line 30

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



43
44
45
46
47
48
# File 'lib/redmine/field_format.rb', line 43

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 {|format| [::I18n.t(format.label), format.name] }.sort_by(&:first)
end

.available_formatsObject



34
35
36
# File 'lib/redmine/field_format.rb', line 34

def self.available_formats
  all.keys
end

.delete(name) ⇒ Object



26
27
28
# File 'lib/redmine/field_format.rb', line 26

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

.find(name) ⇒ Object



38
39
40
# File 'lib/redmine/field_format.rb', line 38

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



51
52
53
54
55
# File 'lib/redmine/field_format.rb', line 51

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