Sha256: d3b402330d926de579c66771c2ba8143cbf6a3272a90580e0622bde913162cee

Contents?: true

Size: 1.44 KB

Versions: 53

Compression:

Stored size: 1.44 KB

Contents

class Auth::Work::Template
	
	include Mongoid::Document

	embedded_in :cycle, :class_name => "Auth::Work::Cycle"
	field :product_id_to_generate, type: String
	field :amount_generated, type: Float
	field :start_amount, type: Float, default: 0.0

	field :summate, type: Boolean
	field :summate_with_index, type: Integer
	field :create_new_item_if_amount_crosses, default: 1.0

	
	def add_item_to_output_hash(output_hash,template_index) 
		output_hash[product_id_to_generate] = [{:template_id => self.id.to_s, :from => self.start_amount, :to => self.amount_generated, :template_index => template_index, :original_template_id => self.id.to_s}]
		output_hash
	end

	def summate_items(output_hash,template_index)
		template_key = self.summate_with_index || template_index
		output_hash[product_id_to_generate] = []
		self.cycle.output_array.reverse.each_with_index {|prev_citem_output,key|
			prev_citem_output.each_key do |product_id|
				tmp = prev_citem_output[product_id]
				if tmp[:template_index] == template_key
					if (tmp[:to] + self.amount_generated) > self.create_new_item_if_amount_crosses
						add_item_to_output_hash(output_hash,template_index)
					else
						output_hash[product_id_to_generate] << {
							:template_id => tmp[:original_template_id], 
							:from => tmp[:to],
							:to => tmp[:to] + self.amount_generated,
							:template_index => template_index,
							:original_template_id => self.id.to_s
						}
					end
				end				
			end
		}
	end

	
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
wordjelly-auth-1.6.0 app/models/auth/work/template.rb
wordjelly-auth-1.5.9 app/models/auth/work/template.rb
wordjelly-auth-1.5.8 app/models/auth/work/template.rb
wordjelly-auth-1.5.7 app/models/auth/work/template.rb
wordjelly-auth-1.5.6 app/models/auth/work/template.rb
wordjelly-auth-1.5.5 app/models/auth/work/template.rb
wordjelly-auth-1.5.4 app/models/auth/work/template.rb
wordjelly-auth-1.5.3 app/models/auth/work/template.rb
wordjelly-auth-1.5.2 app/models/auth/work/template.rb
wordjelly-auth-1.5.1 app/models/auth/work/template.rb
wordjelly-auth-1.5.0 app/models/auth/work/template.rb
wordjelly-auth-1.4.9 app/models/auth/work/template.rb
wordjelly-auth-1.4.8 app/models/auth/work/template.rb
wordjelly-auth-1.4.7 app/models/auth/work/template.rb
wordjelly-auth-1.4.6 app/models/auth/work/template.rb
wordjelly-auth-1.4.5 app/models/auth/work/template.rb
wordjelly-auth-1.4.4 app/models/auth/work/template.rb
wordjelly-auth-1.4.3 app/models/auth/work/template.rb
wordjelly-auth-1.4.2 app/models/auth/work/template.rb
wordjelly-auth-1.4.0 app/models/auth/work/template.rb