Class: Pageflow::FileTypes
- Inherits:
-
Object
- Object
- Pageflow::FileTypes
- Includes:
- Enumerable
- Defined in:
- lib/pageflow/file_types.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #find_by_collection_name!(collection_name) ⇒ Object
-
#initialize(page_types) ⇒ FileTypes
constructor
A new instance of FileTypes.
- #with_thumbnail_support ⇒ Object
Constructor Details
#initialize(page_types) ⇒ FileTypes
Returns a new instance of FileTypes.
5 6 7 |
# File 'lib/pageflow/file_types.rb', line 5 def initialize(page_types) @page_types = page_types end |
Instance Method Details
#each(&block) ⇒ Object
9 10 11 |
# File 'lib/pageflow/file_types.rb', line 9 def each(&block) @page_types.map(&:file_types).flatten.uniq(&:model).each(&block) end |
#find_by_collection_name!(collection_name) ⇒ Object
13 14 15 16 17 |
# File 'lib/pageflow/file_types.rb', line 13 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 |
#with_thumbnail_support ⇒ Object
19 20 21 22 23 |
# File 'lib/pageflow/file_types.rb', line 19 def with_thumbnail_support select do |file_type| file_type.model.instance_methods.include?(:thumbnail_url) end end |