Class: Pageflow::ThemeCustomizationFile

Inherits:
ApplicationRecord show all
Defined in:
app/models/pageflow/theme_customization_file.rb

Overview

A file that has been uploaded by the user to customize a theme, e.g., to use a custom logo.

Since:

  • 15.7

Defined Under Namespace

Classes: AttachmentContentTypeValidator

Instance Method Summary collapse

Instance Method Details

#attachment_stylesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 15.7



53
54
55
# File 'app/models/pageflow/theme_customization_file.rb', line 53

def attachment_styles
  styles_from_options.except(:original)
end

#file_nameObject

The name of the originally uploaded file

Since:

  • 15.7



35
36
37
# File 'app/models/pageflow/theme_customization_file.rb', line 35

def file_name
  attachment_file_name
end

#options_from_entry_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 15.7



48
49
50
# File 'app/models/pageflow/theme_customization_file.rb', line 48

def options_from_entry_type
  theme_customization.entry_type.theme_files.fetch(type_name.to_sym, {})
end

#styles_from_optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 15.7



58
59
60
61
# File 'app/models/pageflow/theme_customization_file.rb', line 58

def styles_from_options
  styles = options_from_entry_type.fetch(:styles, {})
  styles.respond_to?(:call) ? styles.call(self) : styles
end

#urlsObject

A hash of urls based on the styles that were defined when registering the entry type.

Since:

  • 15.7



41
42
43
44
45
# File 'app/models/pageflow/theme_customization_file.rb', line 41

def urls
  styles_from_options.map { |style, _|
    [style, attachment.url(style)]
  }.to_h
end