Sha256: 96ca93be0902fc71d0318547931301a0627587785d403ba7965aad5656a9323f

Contents?: true

Size: 759 Bytes

Versions: 8

Compression:

Stored size: 759 Bytes

Contents

require_relative 'sorted_resource_list'

module Resync
  # Adds useful methods to {ChangeList} and {ChangeDumpManifest}.
  class BaseChangeList < SortedResourceList
    # Filters the list of changes by change type, modification time, or both.
    # @param of_type [Types::Change] the change type
    # @param in_range [Range<Time>] the range of modification times
    # @return [Array<Resource>] the matching changes, or all changes
    #   if neither +of_type+ nor +in_range+ is specified.
    def changes(of_type: nil, in_range: nil)
      resources.select do |r|
        is_of_type = of_type ? r.change == of_type : true
        is_in_range = in_range ? in_range.cover?(r.modified_time) : true
        is_of_type && is_in_range
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
resync-0.4.2 lib/resync/shared/base_change_list.rb
resync-0.4.1 lib/resync/shared/base_change_list.rb
resync-0.4.0 lib/resync/shared/base_change_list.rb
resync-0.3.4 lib/resync/shared/base_change_list.rb
resync-0.3.3 lib/resync/shared/base_change_list.rb
resync-0.3.2 lib/resync/shared/base_change_list.rb
resync-0.3.1 lib/resync/shared/base_change_list.rb
resync-0.3.0 lib/resync/shared/base_change_list.rb