Module: Mbrao::ContentInterface::ClassMethods
- Defined in:
- lib/mbrao/content_interface.rb
Overview
Class methods.
Instance Method Summary (collapse)
-
- (Content) create(metadata, body)
Creates a content with metadata and body.
-
- (Array) validate_locales(locales, content = nil)
Validates locales for attribute retrieval.
Instance Method Details
- (Content) create(metadata, body)
Creates a content with metadata and body.
44 45 46 47 48 49 |
# File 'lib/mbrao/content_interface.rb', line 44 def create(, body) rv = Mbrao::Content.new rv.body = body.ensure_string.strip (rv, .symbolize_keys) if .is_a?(Hash) rv end |
- (Array) validate_locales(locales, content = nil)
Validates locales for attribute retrieval.
32 33 34 35 36 37 |
# File 'lib/mbrao/content_interface.rb', line 32 def validate_locales(locales, content = nil) locales = locales.ensure_array(no_duplicates: true, compact: true, flatten: true) { |l| l.ensure_string.strip } locales = (locales.empty? ? [Mbrao::Parser.locale] : locales) raise Mbrao::Exceptions::UnavailableLocalization if content && !content.enabled_for_locales?(locales) locales end |