Sha256: a01c599a1461a3eb7161595df07ab5f4fed9368f2116fc97a1915037762df383

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

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

        module ClassMethods
          def acts_as_project_effort
            extend ActsAsProjectEffort::SingletonMethods
            include ActsAsProjectEffort::InstanceMethods
        
            after_initialize :new_project_effort
            after_update     :save_project_effort
            after_save       :save_project_effort
    				after_destroy    :destroy_project_effort
        
            has_one :project_effort, :as => :work_effort_record
        
            [
              :description,
              :description=,
              :facility, 
              :facility=,
              :work_effort_assignments,
              :work_effort_statuses,
              :projected_cost,
              :projected_cost=,
              :projected_completion_time,
              :projected_completion_time=,
              :actual_cost,
              :start,
              :started?,
              :completed?,
              :send_to_status
            ].each do |m| delegate m, :to => :project_effort end
        
          end
        end

        module SingletonMethods
        end

        module InstanceMethods
          def save_project_effort
            self.project_effort.save
          end

          def destroy_project_effort
            self.project_effort.destroy
          end

          def new_project_effort
            if self.new_record? and self.project_effort.nil?
              project_effort = ProjectEffort.new
              self.project_effort = project_effort
              project_effort.work_effort_record = self
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
erp_work_effort-3.1.1 lib/erp_work_effort/extensions/active_record/acts_as_project_effort.rb
erp_work_effort-3.1.0 lib/erp_work_effort/extensions/active_record/acts_as_project_effort.rb
erp_work_effort-3.0.4 lib/erp_work_effort/extensions/active_record/acts_as_project_effort.rb
erp_work_effort-3.0.3 lib/erp_work_effort/extensions/active_record/acts_as_project_effort.rb