Class: CustomFieldValue
- Inherits:
-
Object
- Object
- CustomFieldValue
- Defined in:
- app/models/custom_field_value.rb
Overview
Redmine - project management software Copyright © 2006- 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
-
#custom_field ⇒ Object
Returns the value of attribute custom_field.
-
#customized ⇒ Object
Returns the value of attribute customized.
-
#value ⇒ Object
Returns the value of attribute value.
-
#value_was ⇒ Object
Returns the value of attribute value_was.
Instance Method Summary collapse
- #custom_field_id ⇒ Object
- #editable? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ CustomFieldValue
constructor
A new instance of CustomFieldValue.
- #required? ⇒ Boolean
- #to_s ⇒ Object
- #true? ⇒ Boolean
- #validate_value ⇒ Object
- #value_present? ⇒ Boolean
- #visible? ⇒ Boolean
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_field ⇒ Object
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 |
#customized ⇒ Object
Returns the value of attribute customized.
21 22 23 |
# File 'app/models/custom_field_value.rb', line 21 def customized @customized end |
#value ⇒ Object
Returns the value of attribute value.
22 23 24 |
# File 'app/models/custom_field_value.rb', line 22 def value @value end |
#value_was ⇒ Object
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_id ⇒ Object
30 31 32 |
# File 'app/models/custom_field_value.rb', line 30 def custom_field_id custom_field.id end |
#editable? ⇒ Boolean
38 39 40 |
# File 'app/models/custom_field_value.rb', line 38 def editable? custom_field.editable? end |
#required? ⇒ Boolean
46 47 48 |
# File 'app/models/custom_field_value.rb', line 46 def required? custom_field.is_required? end |
#to_s ⇒ Object
50 51 52 |
# File 'app/models/custom_field_value.rb', line 50 def to_s value.to_s end |
#true? ⇒ Boolean
34 35 36 |
# File 'app/models/custom_field_value.rb', line 34 def true? self.value == '1' end |
#validate_value ⇒ Object
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 || customized.errors.add(custom_field.name, ) end end |
#value_present? ⇒ 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
42 43 44 |
# File 'app/models/custom_field_value.rb', line 42 def visible? custom_field.visible? end |