Class: Components::PreviewFrame
- Inherits:
-
Base
- Object
- Base
- Components::PreviewFrame
- Includes:
- Phlex::Rails::Helpers::ImageTag, Phlex::Rails::Helpers::Sanitize
- Defined in:
- app/components/preview_frame.rb
Instance Method Summary collapse
- #before_template ⇒ Object
-
#initialize(object:) ⇒ PreviewFrame
constructor
A new instance of PreviewFrame.
- #view_template ⇒ Object
Constructor Details
#initialize(object:) ⇒ PreviewFrame
Returns a new instance of PreviewFrame.
9 10 11 |
# File 'app/components/preview_frame.rb', line 9 def initialize(object:) @object = object end |
Instance Method Details
#before_template ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/components/preview_frame.rb', line 13 def before_template return if remote? @cover = @object.try(:cover) return if @cover @file = @object if @object.is_a?(ModelFile) @file = @object.preview_file if @object.is_a?(Model) @file = collection_preview_file if @object.is_a?(Collection) end |
#view_template ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/components/preview_frame.rb', line 22 def view_template if @file || @cover render_local elsif remote? render_remote else empty end end |