Sha256: f7f38c881f383cdb9706b9bc5c19312908c207b76183a182012a3a543109090f

Contents?: true

Size: 753 Bytes

Versions: 6

Compression:

Stored size: 753 Bytes

Contents

module VestalVersions
  # Simply adds a flag to determine whether a model class if versioned.
  module Versioned
    def self.extended(base) # :nodoc:
      base.class_eval do
        class << self
          alias_method_chain :versioned, :flag
        end
      end
    end

    # Overrides the +versioned+ method to first define the +versioned?+ class method before
    # deferring to the original +versioned+.
    def versioned_with_flag(*args)
      versioned_without_flag(*args)

      class << self
        def versioned?
          true
        end
      end
    end

    # For all ActiveRecord::Base models that do not call the +versioned+ method, the +versioned?+
    # method will return false.
    def versioned?
      false
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
nickjones-vestal_versions-1.0.3 lib/vestal_versions/versioned.rb
bitfluent-vestal_versions-1.1.0 lib/vestal_versions/versioned.rb
brianjlandau-vestal_versions-1.3.0 lib/vestal_versions/versioned.rb
vestal_versions-1.0.2 lib/vestal_versions/versioned.rb
vestal_versions-1.0.1 lib/vestal_versions/versioned.rb
vestal_versions-1.0.0 lib/vestal_versions/versioned.rb