Class: CustomFields::Model::CustomFieldValue
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- CustomFields::Model::CustomFieldValue
- Defined in:
- lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb
Overview
Model that represents a single custom field value.
Instance Method Summary (collapse)
-
- (String) html
Retrieves the value of the custom field and converts it to the output based on the markup engine specified in the custom field.
-
- (Mixed) value
Retrieves the value and optionally unserializes it.
-
- (Object) value=(val)
Sets the value and serializes it based on the field type.
Methods inherited from Sequel::Model
Instance Method Details
- (String) html
Retrieves the value of the custom field and converts it to the output based on the markup engine specified in the custom field.
55 56 57 |
# File 'lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb', line 55 def html return ::Zen::Markup.convert(custom_field.format, value) end |
- (Mixed) value
Retrieves the value and optionally unserializes it.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb', line 37 def value val = super type = custom_field.custom_field_type if !type.nil? and type.serialize == true val = Marshal.load(val.unpack('m')[0]) rescue Marshal.load(val) end return val end |
- (Object) value=(val)
Sets the value and serializes it based on the field type.
21 22 23 24 25 26 27 28 29 |
# File 'lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb', line 21 def value=(val) type = custom_field.custom_field_type if !type.nil? and type.serialize == true val = [Marshal.dump(val)].pack('m') end super(val) end |