Class: CustomFieldValue

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

Overview

Redmine - project management software Copyright (C) 2006-2016 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



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

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



19
20
21
# File 'app/models/custom_field_value.rb', line 19

def custom_field
  @custom_field
end

#customizedObject

Returns the value of attribute customized



19
20
21
# File 'app/models/custom_field_value.rb', line 19

def customized
  @customized
end

#valueObject

Returns the value of attribute value



19
20
21
# File 'app/models/custom_field_value.rb', line 19

def value
  @value
end

#value_wasObject

Returns the value of attribute value_was



19
20
21
# File 'app/models/custom_field_value.rb', line 19

def value_was
  @value_was
end

Instance Method Details

#custom_field_idObject



27
28
29
# File 'app/models/custom_field_value.rb', line 27

def custom_field_id
  custom_field.id
end

#editable?Boolean

Returns:

  • (Boolean)


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

def editable?
  custom_field.editable?
end

#required?Boolean

Returns:

  • (Boolean)


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

def required?
  custom_field.is_required?
end

#to_sObject



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

def to_s
  value.to_s
end

#true?Boolean

Returns:

  • (Boolean)


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

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

#validate_valueObject



55
56
57
58
59
# File 'app/models/custom_field_value.rb', line 55

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

#visible?Boolean

Returns:

  • (Boolean)


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

def visible?
  custom_field.visible?
end