Sha256: aaf97f84c7fb4b082c4dd7b763a0cafef9705f44e49c46e78492ae22c27b502f
Contents?: true
Size: 874 Bytes
Versions: 11
Compression:
Stored size: 874 Bytes
Contents
module Mobility module ActiveModel =begin Included into model if model has +ActiveModel::AttributeMethods+ among its ancestors. =end module AttributeMethods delegate :translated_attribute_names, to: :class # Adds translated attributes to +attributes+. # @return [Array<String>] Model attributes # @!method attributes def self.included(model) model.class_eval do alias_method :untranslated_attributes, :attributes def attributes super.merge(translated_attributes) end end end # Translated attributes defined on model. # @return [Array<String>] Translated attributes def translated_attributes translated_attribute_names.inject({}) do |attributes, name| attributes.merge(name.to_s => send(name)) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems