Sha256: 835743a67ac1d4b0491ff882de41f08000614e22057dc8bd71633cd5448e372d
Contents?: true
Size: 815 Bytes
Versions: 5
Compression:
Stored size: 815 Bytes
Contents
module Mobility =begin Instance methods attached to all model classes when model includes or extends {Mobility}. =end module InstanceMethods # Fetch backend for an attribute # @param [String] attribute Attribute def mobility_backend_for(attribute) send(Backend.method_name(attribute)) end private def mobility_get(*args) mobility_read(*args).presence end def mobility_present?(*args) mobility_read(*args).present? end def mobility_set(attribute, value, locale: Mobility.locale) mobility_backend_for(attribute).write(locale.to_sym, value.presence) end def mobility_read(attribute, **options) locale = options.delete(:locale) || Mobility.locale mobility_backend_for(attribute).read(locale.to_sym, options) end end end
Version data entries
5 entries across 5 versions & 1 rubygems