Class: Pageflow::Site
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pageflow::Site
- Defined in:
- app/models/pageflow/site.rb
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(_auth_object = nil) ⇒ Object
Instance Method Summary collapse
- #cname_domain ⇒ Object
- #display_name ⇒ Object
- #existing_and_potential_entry_templates ⇒ Object
- #first_paged_entry_template ⇒ Object
- #host ⇒ Object
- #name_with_account_prefix ⇒ Object
-
#theme_name ⇒ Object
deprecated
Deprecated.
Depending on what you need this for, consider
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
63 64 65 |
# File 'app/models/pageflow/site.rb', line 63 def self.ransackable_associations(_auth_object = nil) %w[account] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
59 60 61 |
# File 'app/models/pageflow/site.rb', line 59 def self.ransackable_attributes(_auth_object = nil) %w[name] end |
Instance Method Details
#cname_domain ⇒ Object
28 29 30 |
# File 'app/models/pageflow/site.rb', line 28 def cname_domain cname.split('.').pop(2).join('.') end |
#display_name ⇒ Object
16 17 18 |
# File 'app/models/pageflow/site.rb', line 16 def display_name name.presence || I18n.t('pageflow.admin.sites.default_name') end |
#existing_and_potential_entry_templates ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/pageflow/site.rb', line 36 def existing_and_potential_entry_templates entry_type_names = Pageflow.config_for(account).entry_types.map(&:name) allowed_existing_entry_templates = entry_templates.where(entry_type_name: entry_type_names) free_type_names = entry_type_names - allowed_existing_entry_templates.map(&:entry_type_name) potential_entry_templates = free_type_names.map do |type_name| entry_templates.build(entry_type_name: type_name) end allowed_existing_entry_templates + potential_entry_templates end |
#first_paged_entry_template ⇒ Object
32 33 34 |
# File 'app/models/pageflow/site.rb', line 32 def first_paged_entry_template entry_templates.find_or_initialize_by(entry_type_name: 'paged') end |
#host ⇒ Object
24 25 26 |
# File 'app/models/pageflow/site.rb', line 24 def host Pageflow.config.(self)&.dig(:host) end |
#name_with_account_prefix ⇒ Object
20 21 22 |
# File 'app/models/pageflow/site.rb', line 20 def name_with_account_prefix [account.name, name].compact.join(' - ') end |
#theme_name ⇒ Object
Deprecated.
Depending on what you need this for, consider
scoping your code to an entry type or look at a specific entry’s theme name.
55 56 57 |
# File 'app/models/pageflow/site.rb', line 55 def theme_name first_paged_entry_template.theme_name end |