Sha256: 2c643ae281f5e4bcc4631477517c9afe2cee7252900e27a9dafb1f2914d17c80
Contents?: true
Size: 1.05 KB
Versions: 9
Compression:
Stored size: 1.05 KB
Contents
# encoding: utf-8 module LocalizableModel # = LocalizableModel::ActiveRecordExtension # # Extends ActiveRecord::Base with the localizable setup method. # module ActiveRecordExtension # Extends the model with Localizable features. # It takes an optional block as argument, which yields an instance of # LocalizableModel::Configuration. # # Example: # # class Page < ActiveRecord::Base # localizable do # attribute :name # attribute :body # end # end # def localizable(&block) unless is_a?(LocalizableModel::ClassMethods) send :extend, LocalizableModel::ClassMethods send :include, LocalizableModel::InstanceMethods has_many(:localizations, as: :localizable, dependent: :destroy, autosave: true) before_save :cleanup_localizations! end localizable_configuration.instance_eval(&block) if block_given? end end end ActiveRecord::Base.send(:extend, LocalizableModel::ActiveRecordExtension)
Version data entries
9 entries across 9 versions & 1 rubygems