class CustomAttributes::CustomFieldValue
Decorator for CustomValues
Attributes
custom_field[RW]
customizable[RW]
value[RW]
value_was[RW]
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 6 def initialize(attributes = {}) attributes.each do |name, v| send "#{name}=", v end end
Public Instance Methods
custom_field_id()
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 12 def custom_field_id custom_field.id end
custom_field_slug()
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 16 def custom_field_slug custom_field.slug end
required?()
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 28 def required? custom_field.is_required? end
serializable_hash(options = nil)
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 36 def serializable_hash(options = nil) { custom_field_id: self.custom_field_id, value: self.value }.as_json end
to_s()
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 32 def to_s value.to_s end
true?()
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 20 def true? value == '1' end
validate_value()
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 52 def validate_value custom_field.validate_custom_value(self).each do |message| customizable.errors.add(:base, custom_field.name + ' ' + message) end end
value=(v)
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 40 def value=(v) @value = custom_field.set_custom_field_value(self, v) end
value_present?()
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 44 def value_present? if value.is_a?(Array) value.any?(&:present?) else value.present? end end
visible?()
click to toggle source
# File lib/custom_attributes/custom_field_value.rb, line 24 def visible? custom_field.visible? end