Sha256: 9459eac6f9d9e6a2d0178cf1f635446a4c5248e3ea6371ab59d66c025e5004fe
Contents?: true
Size: 800 Bytes
Versions: 12
Compression:
Stored size: 800 Bytes
Contents
# frozen_string_literal: true # rubocop:disable Style/ClassAndModuleChildren module Maglev::Site::LocalesConcern extend ActiveSupport::Concern included do ## serializers ## serialize :locales, LocalesSerializer ## validation ## validates :locales, 'maglev/collection': true, length: { minimum: 1 } end def default_locale locales.first end def default_locale_prefix default_locale.prefix.to_sym end def locale_prefixes locales.map { |locale| locale.prefix.to_sym } end class LocalesSerializer def self.dump(array) (array || []).map(&:as_json) end def self.load(array) (array || []).map { |attributes| Maglev::Site::Locale.new(**attributes.symbolize_keys) } end end end # rubocop:enable Style/ClassAndModuleChildren
Version data entries
12 entries across 12 versions & 1 rubygems