Class: Maglev::Site

Inherits:
ApplicationRecord show all
Includes:
SectionsConcern, LocalesConcern, Translatable
Defined in:
app/models/maglev/site.rb

Defined Under Namespace

Modules: LocalesConcern Classes: Locale, StyleValue

Instance Method Summary collapse

Methods included from Translatable

#translate_attr_in, #translations_for

Methods included from SectionsConcern

#delete_section, #find_section_block_by_id, #find_section_by_id, #find_sections_by_type, #position_of_section, #prepare_sections, #prepare_sections_translations, #reorder_sections, #section_ids

Methods included from LocalesConcern

#add_locale, #default_locale, #default_locale_prefix, #each_locale, #locale_prefixes, #many_locales?

Methods inherited from ApplicationRecord

mysql?

Instance Method Details

#api_attributesObject



43
44
45
# File 'app/models/maglev/site.rb', line 43

def api_attributes
  %i[id name]
end

#find_section(type) ⇒ Object



47
48
49
# File 'app/models/maglev/site.rb', line 47

def find_section(type)
  sections&.find { |section| section['type'] == type }
end

#nameObject

validations ##



35
# File 'app/models/maglev/site.rb', line 35

validates :name, presence: true

#published?Boolean

methods ##

Returns:

  • (Boolean)


39
40
41
# File 'app/models/maglev/site.rb', line 39

def published?
  published_at.present?
end

#sectionsObject

translations ##



32
# File 'app/models/maglev/site.rb', line 32

translates :sections

#sections_content_storesObject

associations ##



25
# File 'app/models/maglev/site.rb', line 25

has_many :sections_content_stores, as: :container, dependent: :destroy

#styleObject

force JSON columns for MariaDB ##



28
# File 'app/models/maglev/site.rb', line 28

attribute :style, :json

#translate_in(locale, source_locale) ⇒ Object



51
52
53
# File 'app/models/maglev/site.rb', line 51

def translate_in(locale, source_locale)
  translate_attr_in(:sections, locale, source_locale)
end