Sha256: 2ee06e7a59866c68bde2deb84af5eb2eb9e1a7a173083f64ee1d267df6e68a1e

Contents?: true

Size: 466 Bytes

Versions: 2

Compression:

Stored size: 466 Bytes

Contents

# frozen_string_literal: true

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tramway-0.2.1.2 lib/tramway/decorators/collection_decorator.rb
tramway-0.2.1.1 lib/tramway/decorators/collection_decorator.rb