Module: Mbrao::ContentPublicInterface

Included in:
Content
Defined in:
lib/mbrao/content.rb

Overview

Setter methods for the Content class.

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) enabled_for_locales?(*locales)

Checks if the content is available for at least one of the provided locales.

Parameters:

  • locales (Array)

    The desired locales. Can include * to match all. If none are specified, the default mbrao locale will be used.

Returns:

  • (Boolean)

    true if the content is available for at least one of the desired locales, false otherwise.



14
15
16
17
# File 'lib/mbrao/content.rb', line 14

def enabled_for_locales?(*locales)
  locales = locales.flatten.ensure_array(nil, false, false, true) {|l| l.ensure_string.strip }.reject {|l| l == "*" }
  @locales.blank? || locales.blank? || (@locales & locales).present?
end

- (String|HashWithIndifferentAccess) get_body(locales = [], engine = :plain_text)

Gets the body returning only the portion which are available for the given locales.

Parameters:

  • locales (String|Array) (defaults to: [])

    The desired locales. Can include * to match all. If none are specified, the default mbrao locale will be used.

  • engine (String|Symbol|Object) (defaults to: :plain_text)

    The engine to use to filter contents.

Returns:

  • (String|HashWithIndifferentAccess)

    Return the body of the content in the desired locales. If only one locale is required, then a String is returned, else a HashWithIndifferentAccess with locales as keys.



34
35
36
# File 'lib/mbrao/content.rb', line 34

def get_body(locales = [], engine = :plain_text)
  Mbrao::Parser.create_engine(engine).filter_content(self, locales)
end

- (String|HashWithIndifferentAccess) get_more(locales = [])

Gets the “more link” text of the content in the desired locales.

Parameters:

  • locales (String|Array) (defaults to: [])

    The desired locales. Can include * to match all. If none are specified, the default mbrao locale will be used.

Returns:

  • (String|HashWithIndifferentAccess)

    Return the label of the “more link” of the content in the desired locales. If only one locale is required, then a String is returned, else a HashWithIndifferentAccess with locales as keys.



52
53
54
# File 'lib/mbrao/content.rb', line 52

def get_more(locales = [])
  filter_attribute_for_locales(@more, locales)
end

- (Array|HashWithIndifferentAccess) get_tags(locales = [])

Gets the tags of the content in the desired locales.

Parameters:

  • locales (String|Array) (defaults to: [])

    The desired locales. Can include * to match all. If none are specified, the default mbrao locale will be used.

Returns:

  • (Array|HashWithIndifferentAccess)

    Return the title of the content in the desired locales. If only one locale is required, then a Array is returned, else a HashWithIndifferentAccess with locales as keys.



43
44
45
# File 'lib/mbrao/content.rb', line 43

def get_tags(locales = [])
  filter_attribute_for_locales(@tags, locales)
end

- (String|HashWithIndifferentAccess) get_title(locales = [])

Gets the title of the content in the desired locales.

Parameters:

  • locales (String|Array) (defaults to: [])

    The desired locales. Can include * to match all. If none are specified, the default mbrao locale will be used.

Returns:

  • (String|HashWithIndifferentAccess)

    Return the title of the content in the desired locales. If only one locale is required, then a String is returned, else a HashWithIndifferentAccess with locales as keys.



24
25
26
# File 'lib/mbrao/content.rb', line 24

def get_title(locales = [])
  filter_attribute_for_locales(@title, locales)
end