Created
September 7, 2010 21:32
-
-
Save bill-transue/569154 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 Cabinet < ActiveRecord::Base | |
| has_many :components do | |
| def front_facing | |
| all(:conditions => {:orientation => "A"}) | |
| end | |
| def front_facing_grouped_by_elevation_index | |
| front_facing.group_by{|component| component.elevation_index - component.component_model.height + 1} | |
| end | |
| def back_facing | |
| all(:conditions => {:orientation => "AB"}) | |
| end | |
| def back_facing_grouped_by_elevation_index | |
| front_facing.group_by{|component| component.elevation_index - component.component_model.height + 1} | |
| end | |
| def left_facing | |
| all(:conditions => {:orientation => "AA"}) | |
| end | |
| def left_facing_grouped_by_elevation_index | |
| left_facing.group_by{|component| component.elevation_index - component.component_model.height + 1} | |
| end | |
| def right_facing | |
| all(:conditions => {:orientation => "A"}) | |
| end | |
| def right_facing_grouped_by_elevation_index | |
| front_facing.group_by{|component| component.elevation_index - component.component_model.height + 1} | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment