Created
November 8, 2011 00:23
-
-
Save HeroicEric/1346637 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ProductDecorator < ApplicationDecorator | |
| decorates :product | |
| # Gets all of the OptionValues that is used by a Variant of the Product | |
| # | |
| # Returns an Array of OptionValues | |
| def option_values | |
| option_values = [] | |
| model.variants.each do |variant| | |
| option_values << variant.option_values | |
| end | |
| option_values.flatten.uniq | |
| end | |
| # Groups the OptionValues with their OptionType | |
| # | |
| # Returns a Hash with OptionTypes as keys and an Array of OptionValues for values | |
| def grouped_option_values | |
| option_values.group_by(&:option_type) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment