Sha256: d41386cd1a803bd04ca8937862025cb1c62df472d00f423bec43d0dcb4b1faa5
Contents?: true
Size: 1.17 KB
Versions: 10
Compression:
Stored size: 1.17 KB
Contents
module ErpBaseErpSvcs module Extensions module ActiveRecord module ActsAsCategory def self.included(base) base.extend(ClassMethods) end module ClassMethods def acts_as_category extend ActsAsCategory::SingletonMethods include ActsAsCategory::InstanceMethods after_initialize :initialize_category after_create :save_category after_update :save_category after_destroy :destroy_category has_one :category, :as => :category_record end end module SingletonMethods end module InstanceMethods def method_missing(name, *args) self.category.respond_to?(name) ? self.category.send(name, *args) : super end def save_category self.category.save end def destroy_category self.category.destroy end def initialize_category if self.new_record? and self.category.nil? category = Category.new self.category = category category.category_record = self end end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems