Sha256: 79e7fe45930f275b05874ed4294c716e66e865574b9764485d7c8722c032b64a

Contents?: true

Size: 887 Bytes

Versions: 13

Compression:

Stored size: 887 Bytes

Contents

=begin rdoc
This class stores version text for Contact. See Version for details.

=== Content

Uses ContactContent.
=end
class ContactVersion < Version

  def self.content_class
    ContactContent
  end

  def redaction_content
    @old_fullname ||= content.fullname
    super
  end

  private
    def version_before_validation
      if title.blank?
        self.title = content.fullname
      elsif content.fullname.blank?
        if title =~ /^(\S+)\s+(.*)$/
          content.first_name = $1
          content.name = $2
        else
          content.name = title
        end
      end

      if title_changed? && content.fullname_changed?
        # ignore if both title and fullname changed
      elsif content.fullname_changed? && title == content.fullname_was
        # fullname changed and title was in sync
        self.title = content.fullname
      end
      super
    end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
zena-0.16.9 app/models/contact_version.rb
zena-0.16.8 app/models/contact_version.rb
zena-0.16.7 app/models/contact_version.rb
zena-0.16.6 app/models/contact_version.rb
zena-0.16.5 app/models/contact_version.rb
zena-0.16.4 app/models/contact_version.rb
zena-0.16.3 app/models/contact_version.rb
zena-0.16.2 app/models/contact_version.rb
zena-0.16.1 app/models/contact_version.rb
zena-0.16.0 app/models/contact_version.rb
zena-0.15.2 app/models/contact_version.rb
zena-0.15.1 app/models/contact_version.rb
zena-0.15.0 app/models/contact_version.rb