Sha256: 062610bbf9f66c6353e3d1799c7ce520861298515db8f0e111843069ac7e7c9e
Contents?: true
Size: 985 Bytes
Versions: 9
Compression:
Stored size: 985 Bytes
Contents
module CustomAttributes # Decorator for CustomValues class CustomFieldValue attr_accessor :custom_field, :customizable, :value, :value_was def initialize(attributes = {}) attributes.each do |name, v| send "#{name}=", v end end def custom_field_id custom_field.id end def custom_field_slug custom_field.slug end def true? value == '1' end def visible? custom_field.visible? end def required? custom_field.is_required? end def to_s value.to_s end def value=(v) @value = custom_field.set_custom_field_value(self, v) end def value_present? if value.is_a?(Array) value.any?(&:present?) else value.present? end end def validate_value custom_field.validate_custom_value(self).each do |message| customizable.errors.add(:base, custom_field.name + ' ' + message) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems