Sha256: f218d13a1908dc7ce721950bd7f133f3298e99440a313d9b8270db963516fb08

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 KB

Contents

module ErpWorkEffort
	module Extensions
		module ActiveRecord
			module ActsAsProjectRequirement
			  
        def self.included(base)
          base.extend(ClassMethods)
        end

        module ClassMethods
          def acts_as_project_requirement
            extend ActsAsProjectRequirement::SingletonMethods
            include ActsAsProjectRequirement::InstanceMethods
        
            after_initialize :new_project_requirement
            after_update     :save_project_requirement
            after_save       :save_project_requirement
    				after_destroy    :destroy_project_requirement
        
            has_one :project_requirement, :as => :work_requirement_record
        
            [
              :description,
              :description=,
              :facility,
              :facility=,
              :valid_work_assignments,
              :work_requirement_work_effort_status_types,
              :work_effort_status_types,
              :projected_cost=,
              :projected_cost,
              :projected_completion_time,
              :projected_completion_time=,
              :add_status_type,
              :add_status_type=
            ].each do |m| delegate m, :to => :project_requirement end
        
          end
        end

        module SingletonMethods
        end

        module InstanceMethods
          def save_project_requirement
            self.project_requirement.save
          end

          def destroy_project_requirement
            self.project_requirement.destroy
          end

          def new_project_requirement
            if (self.project_requirement.nil?)
              project_requirement = ProjectRequirement.new
              self.project_requirement = project_requirement
              project_requirement.work_requirement_record = self
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
erp_work_effort-3.1.1 lib/erp_work_effort/extensions/active_record/acts_as_project_requirement.rb
erp_work_effort-3.1.0 lib/erp_work_effort/extensions/active_record/acts_as_project_requirement.rb
erp_work_effort-3.0.4 lib/erp_work_effort/extensions/active_record/acts_as_project_requirement.rb
erp_work_effort-3.0.3 lib/erp_work_effort/extensions/active_record/acts_as_project_requirement.rb
erp_work_effort-3.0.2 lib/erp_work_effort/extensions/active_record/acts_as_project_requirement.rb
erp_work_effort-3.0.1 lib/erp_work_effort/extensions/active_record/acts_as_project_requirement.rb
erp_work_effort-3.0.0 lib/erp_work_effort/extensions/active_record/acts_as_project_requirement.rb