Sha256: c46a580757410778b9723b163bf5a05492113fb2c3a3c828b42877063097fa1a
Contents?: true
Size: 885 Bytes
Versions: 4
Compression:
Stored size: 885 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) value = mobility_read(*args) value == false ? value : value.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 == false ? value : 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
4 entries across 4 versions & 1 rubygems