Sha256: ea21fd8e6150dd7d1f6f6782128bf26a96b718f62812eab51c6e3dd9244662f0

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

#:nodoc:
module CustomFields
  #:nodoc:
  module Model
    ##
    # Model that represents a single custom field value. This model
    # has the following relations:
    #
    # * custom field (many to one)
    # * section entry (many to one)
    #
    # This model is basically just a join table with some extra columns.
    #
    # @author Yorick Peterse
    # @since  0.1
    #
    class CustomFieldValue < Sequel::Model
      many_to_one(:custom_field , :class => "CustomFields::Model::CustomField")
      many_to_one(:section_entry, :class => "Sections::Model::SectionEntry")

      ##
      # Hook that is executed before saving a field's value. This hook is used to clean
      # up all values making it easier to process them at a later stage.
      #
      # @author Yorick Peterse
      # @since  0.2.4
      #
      def before_save
        # T-t-t-t-that's all folks!
        if !self.value.nil?
          self.value.gsub!(/\r\n/, "\n")
        end
      end
    end # CustomFieldValue
  end # Model
end # CustomFields

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zen-0.2.7 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb
zen-0.2.6.1 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb
zen-0.2.6 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb