Sha256: 1c2af949f4a8c292c3ac58f2a56adc21652052e037b3f4dbd2edcecd4b06426f

Contents?: true

Size: 447 Bytes

Versions: 7

Compression:

Stored size: 447 Bytes

Contents

# frozen_string_literal: true

module Tramway
  module Decorators
    # Provides functions for collection decorating
    #
    module CollectionDecorators
      module_function

      def decorate_collection(collection:, decorator:)
        collection.map do |item|
          decorator.decorate item
        end
      end

      def collection?(object)
        object.class.name.in? ['ActiveRecord::Relation', 'Array']
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tramway-0.3.1.2 lib/tramway/decorators/collection_decorator.rb
tramway-0.3.1.1 lib/tramway/decorators/collection_decorator.rb
tramway-0.3.1 lib/tramway/decorators/collection_decorator.rb
tramway-0.3 lib/tramway/decorators/collection_decorator.rb
tramway-0.2.3 lib/tramway/decorators/collection_decorator.rb
tramway-0.2.2 lib/tramway/decorators/collection_decorator.rb
tramway-0.2.1.3 lib/tramway/decorators/collection_decorator.rb