Sha256: f19c55bbf61e79d07c5e7987c1a5b8f658759b1b6a1743565859396bc767d042

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 Bytes

Contents

module Exposant
  class CollectionExhibitor < SimpleDelegator
    include Exhibitor
    extend ActiveModel::Naming
    include Enumerable

    def self.exhibitor_variant
      self::MODEL_PRESENTER_VARIANT if const_defined?('MODEL_PRESENTER_VARIANT')
    end

    def each
      return enum_for(:each) unless block_given?

      __getobj__.each do |o|
        exh = o&.exhibitor(self.class.exhibitor_variant)
        exh.contextualize(context) if exh.present? && contextualized?

        yield exh
      end
    end

    def to_model
      self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exposant-0.1.2 lib/exposant/collection_exhibitor.rb