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

#prepare_sections, #prepare_sections_translations

Methods included from LocalesConcern

#add_locale, #default_locale, #default_locale_prefix, #each_locale, #locale_prefixes

Instance Method Details

#api_attributesObject

methods ##



17
18
19
# File 'app/models/maglev/site.rb', line 17

def api_attributes
  %i[id name]
end

#find_section(type) ⇒ Object



21
22
23
# File 'app/models/maglev/site.rb', line 21

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

#nameObject

validations ##



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

validates :name, presence: true

#sectionsObject

translations ##



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

translates :sections

#translate_in(locale, source_locale) ⇒ Object



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

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