B
Blue Hand Talking
I wonder if someone could explain how the '==' comparison operator
is being used below,
not quite getting it, or even the general flow.
Properties of Class Order:
attr_accessible :line_items
has_many :line_items
accepts_nested_attributes_for :line_items
def compute_order(order)
matched_line_items = order.line_items.select do |line_item|
line_item.product.tax_category == rate.tax_category
end
line_items_total = matched_line_items.sum(&:total)
round_to_two_places(line_items_total * rate.amount)
end
Would 'matched_line_items' be an array of product objects with
their tax_category value set from this operation?
If so, how is this happening? Seems that the comparison would be
returning true or false.
Also, here is Product#tax_category method:
def tax_category
if self[:tax_category_id].nil?
TaxCategory.whereis_default => true).first
else
TaxCategory.find(self[:tax_category_id])
end
end
Thanks,
Jet
is being used below,
not quite getting it, or even the general flow.
Properties of Class Order:
attr_accessible :line_items
has_many :line_items
accepts_nested_attributes_for :line_items
def compute_order(order)
matched_line_items = order.line_items.select do |line_item|
line_item.product.tax_category == rate.tax_category
end
line_items_total = matched_line_items.sum(&:total)
round_to_two_places(line_items_total * rate.amount)
end
Would 'matched_line_items' be an array of product objects with
their tax_category value set from this operation?
If so, how is this happening? Seems that the comparison would be
returning true or false.
Also, here is Product#tax_category method:
def tax_category
if self[:tax_category_id].nil?
TaxCategory.whereis_default => true).first
else
TaxCategory.find(self[:tax_category_id])
end
end
Thanks,
Jet