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

Version Path
erp_base_erp_svcs-4.0.0 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.1.5 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.1.4 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.1.3 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.1.2 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.1.1 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.0.7 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.1.0 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.0.6 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.0.5 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.0.4 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.0.3 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.0.2 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.0.1 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb
erp_base_erp_svcs-3.0.0 lib/erp_base_erp_svcs/extensions/active_record/is_describable.rb