Sha256: c2d22eb0dcadec8b47e84f3d1b5085dc1031c382e14b44f9cd6b78f9ec1570ee

Contents?: true

Size: 631 Bytes

Versions: 17

Compression:

Stored size: 631 Bytes

Contents

module Pageflow
  class FileTypes
    include Enumerable

    def initialize(page_types)
      @page_types = page_types
    end

    def each(&block)
      @page_types.map(&:file_types).flatten.uniq(&:model).each(&block)
    end

    def find_by_collection_name!(collection_name)
      detect do |file_type|
        file_type.collection_name == collection_name
      end || raise(FileType::NotFoundError, "No file type found for collection name '#{collection_name}'.")
    end

    def with_thumbnail_support
      select do |file_type|
        file_type.model.instance_methods.include?(:thumbnail_url)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pageflow-0.11.4 lib/pageflow/file_types.rb
pageflow-0.11.3 lib/pageflow/file_types.rb
pageflow-0.11.2 lib/pageflow/file_types.rb
pageflow-0.11.1 lib/pageflow/file_types.rb
pageflow-0.11.0 lib/pageflow/file_types.rb
pageflow-0.10.0 lib/pageflow/file_types.rb
pageflow-0.9.2 lib/pageflow/file_types.rb
pageflow-0.9.1 lib/pageflow/file_types.rb
pageflow-0.9.0 lib/pageflow/file_types.rb
pageflow-0.8.2 lib/pageflow/file_types.rb
pageflow-0.8.1 lib/pageflow/file_types.rb
pageflow-0.8.0 lib/pageflow/file_types.rb
pageflow-0.7.2 lib/pageflow/file_types.rb
pageflow-0.7.1 lib/pageflow/file_types.rb
pageflow-0.7.0 lib/pageflow/file_types.rb
pageflow-0.6.0 lib/pageflow/file_types.rb
pageflow-0.5.0 lib/pageflow/file_types.rb