Sha256: 4d298f87279286a06f36062f70038610c87e52ed91f3729fece461e8e30ca1db

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 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
      
      class << self
        
        # Marshal helper.
        #
        def load( data )
          new.marshal_load( data )
        end
        
      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

3 entries across 3 versions & 1 rubygems

Version Path
methodmissing-scrooge-1.0.2 lib/scrooge/tracker/base.rb
methodmissing-scrooge-1.0.3 lib/scrooge/tracker/base.rb
methodmissing-scrooge-1.0.4 lib/scrooge/tracker/base.rb