Sha256: bf1d3f0ecb0c0a7311c48208c8b23e204cd8157c4b4a7b48ee3982ce981f1992

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'set'

module Scrooge
  module Tracker
    
    autoload :App, 'scrooge/tracker/app'
    autoload :Resource, 'scrooge/tracker/resource'
    autoload :Model, 'scrooge/tracker/model'
    
    class Base < Scrooge::Base
      include Comparable      
      
      # Scrooge Tracker base class.
      
      class NotImplemented < StandardError
      end
      
      attr_accessor :counter
      
      def initialize
        @counter = 0
      end
      
      def to_i
        @counter  
      end
      
      # Requires subclasses to implement a custom marshal_dump
      #
      def marshal_dump
        raise NotImplemented
      end

      # Requires subclasses to implement a custom marshal_load
      #      
      def marshal_load( data )
        raise NotImplemented
      end
      
      # Compare trackers through their Marshal representations.
      #
      def ==( tracker )
        compare_to( tracker )
      end
      alias :eql? :==
      alias :<=> :==
      
      private
        
        def compare_to( tracker ) #:nodoc:
          marshal_dump == tracker.marshal_dump
        end
          
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
methodmissing-scrooge-1.0.0 lib/scrooge/tracker/base.rb
methodmissing-scrooge-1.0.1 lib/scrooge/tracker/base.rb