Class: CustomValue

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/custom_value.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

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.

See doc/COPYRIGHT.rdoc for more details. ++

Instance Method Summary collapse

Instance Method Details

#after_initializeObject


19
20
21
22
23
# File 'app/models/custom_value.rb', line 19

def after_initialize
  if new_record? && custom_field && (customized_type.blank? || (customized && customized.new_record?))
    self.value ||= custom_field.default_value
  end
end

#editable?Boolean

Returns:

  • (Boolean)

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

def editable?
  custom_field.editable?
end

#required?Boolean

Returns:

  • (Boolean)

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

def required?
  custom_field.is_required?
end

#to_sObject


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

def to_s
  value.to_s
end

#true?Boolean

Returns true if the boolean custom value is true

Returns:

  • (Boolean)

26
27
28
# File 'app/models/custom_value.rb', line 26

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

#visible?Boolean

Returns:

  • (Boolean)

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

def visible?
  custom_field.visible?
end