Class: CustomFieldValue

Inherits:
Object
  • Object
show all
Defined in:
app/models/custom_field_value.rb

Overview

Redmine - project management software Copyright © 2006-2022 Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CustomFieldValue

Returns a new instance of CustomFieldValue.



24
25
26
27
28
# File 'app/models/custom_field_value.rb', line 24

def initialize(attributes={})
  attributes.each do |name, v|
    send "#{name}=", v
  end
end

Instance Attribute Details

#custom_fieldObject

Returns the value of attribute custom_field.



21
22
23
# File 'app/models/custom_field_value.rb', line 21

def custom_field
  @custom_field
end

#customizedObject

Returns the value of attribute customized.



21
22
23
# File 'app/models/custom_field_value.rb', line 21

def customized
  @customized
end

#valueObject

Returns the value of attribute value.



22
23
24
# File 'app/models/custom_field_value.rb', line 22

def value
  @value
end

#value_wasObject

Returns the value of attribute value_was.



21
22
23
# File 'app/models/custom_field_value.rb', line 21

def value_was
  @value_was
end

Instance Method Details

#custom_field_idObject



30
31
32
# File 'app/models/custom_field_value.rb', line 30

def custom_field_id
  custom_field.id
end

#editable?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/custom_field_value.rb', line 38

def editable?
  custom_field.editable?
end

#required?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/models/custom_field_value.rb', line 46

def required?
  custom_field.is_required?
end

#to_sObject



50
51
52
# File 'app/models/custom_field_value.rb', line 50

def to_s
  value.to_s
end

#true?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/custom_field_value.rb', line 34

def true?
  self.value == '1'
end

#validate_valueObject



66
67
68
69
70
# File 'app/models/custom_field_value.rb', line 66

def validate_value
  custom_field.validate_custom_value(self).each do |message|
    customized.errors.add(custom_field.name, message)
  end
end

#value_present?Boolean

Returns:

  • (Boolean)


58
59
60
61
62
63
64
# File 'app/models/custom_field_value.rb', line 58

def value_present?
  if value.is_a?(Array)
    value.any?(&:present?)
  else
    value.present?
  end
end

#visible?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/custom_field_value.rb', line 42

def visible?
  custom_field.visible?
end