Sha256: 211ae02d07cf9f6cdaa93861f3654fd1147babfe86b83b846ad1c7c8741753ea

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

module ErpBaseErpSvcs
	module Extensions
		module ActiveRecord
			module ActsAsNoteType
				def self.included(base)
				  base.extend(ClassMethods)
				end

				module ClassMethods
				  def acts_as_note_type
            extend ActsAsNoteType::SingletonMethods
  					include ActsAsNoteType::InstanceMethods
  					
					  after_initialize :initialize_note_type
  					after_create :save_note_type
  					after_update :save_note_type
  					after_destroy :destroy_note_type
					
					  has_one :note_type_record, :as => :note_type_record, :class_name => 'NoteType'
				  end
				end

				module SingletonMethods
				end

				module InstanceMethods
				  def save_note_type
					  self.note_type_record.save
				  end

				  def destroy_note_type
					  self.note_type_record.destroy
				  end

				  def initialize_note_type
					  if self.new_record? and self.note_type_record.nil?
					    note_type_record = NoteType.new
					    self.note_type_record = note_type_record
					    self.note_type_record.note_type_record = self
					  end
				  end
				  
				end
			end
		end
	end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
erp_base_erp_svcs-4.2.0 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-4.0.0 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.1.5 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.1.4 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.1.3 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.1.2 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.1.1 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.0.7 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.1.0 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.0.6 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb
erp_base_erp_svcs-3.0.5 lib/erp_base_erp_svcs/extensions/active_record/acts_as_note_type.rb