Sha256: e8e35312a3860bbdabaa67b2532568cfa0e5960b45533405e52a00a553c1c4a4
Contents?: true
Size: 1.15 KB
Versions: 15
Compression:
Stored size: 1.15 KB
Contents
module ErpBaseErpSvcs module Extensions module ActiveRecord module IsDescribable def self.included(base) base.extend(ClassMethods) end module ClassMethods def is_describable has_many :descriptions, :class_name => 'DescriptiveAsset', :as => :described_record, :dependent => :destroy extend IsDescribable::SingletonMethods include IsDescribable::InstanceMethods end end module SingletonMethods end module InstanceMethods def find_descriptions_by_view_type(view_iid) self.descriptions.where('view_type_id = ?', ViewType.find_by_internal_identifier(view_iid).id) end def find_description_by_iid(iid) self.descriptions.where('internal_identifier = ?', iid).first end def add_description(view_type, description) descriptive_asset = DescriptiveAsset.create( :view_type => view_type, :description => description) descriptive_asset.described_record = self self.descriptions << descriptive_asset end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems