Sha256: 80288f827363f77ba015f5e6a94ade751ca34ed5cc130cbecb82bbba64b7b06d
Contents?: true
Size: 971 Bytes
Versions: 30
Compression:
Stored size: 971 Bytes
Contents
module Mobility module Plugins module ActiveRecord module TranslatedAttributes def translated_attributes {} end def attributes super.merge(translated_attributes) end end =begin Module builder adding translated attributes to #attributes hash on model instance. See {Mobility::Plugins::AttributeMethods} for further details. =end class AttributeMethods < Module def initialize(*attribute_names) include TranslatedAttributes define_method :translated_attributes do super().merge(attribute_names.inject({}) do |attributes, name| attributes.merge(name.to_s => send(name)) end) end end def included(model_class) model_class.class_eval do define_method :untranslated_attributes, ::ActiveRecord::Base.instance_method(:attributes) end end end end end end
Version data entries
30 entries across 30 versions & 1 rubygems