Class/Module Index [+]

Quicksearch

Mongoid::Fields::Localized

Public Instance Methods

demongoize(object) click to toggle source

Demongoize the object based on the current locale. Will look in the hash for the current locale.

@example Get the demongoized value.

field.demongoize({ "en" => "testing" })

@param [ Hash ] object The hash of translations.

@return [ Object ] The value for the current locale.

@since 2.3.0

# File lib/mongoid/fields/localized.rb, line 16
def demongoize(object)
  if object
    type.demongoize(lookup(object))
  end
end
localized?() click to toggle source

Is the field localized or not?

@example Is the field localized?

field.localized?

@return [ true, false ] If the field is localized.

@since 2.3.0

# File lib/mongoid/fields/localized.rb, line 30
def localized?
  true
end
mongoize(object) click to toggle source

Convert the provided string into a hash for the locale.

@example Serialize the value.

field.mongoize("testing")

@param [ String ] object The string to convert.

@return [ Hash ] The locale with string translation.

@since 2.3.0

# File lib/mongoid/fields/localized.rb, line 44
def mongoize(object)
  { ::I18n.locale.to_s => type.mongoize(object) }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.