Created
September 8, 2010 17:15
-
-
Save bill-transue/570437 to your computer and use it in GitHub Desktop.
This file contains 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 Component < ActiveRecord::Base | |
belongs_to :cabinet | |
belongs_to :component_model | |
has_many :port, :as => :device, :extend => CreatePortFromModel | |
has_many :sub_components | |
def elevation | |
orientation + elevation_index.to_s | |
end | |
named_scope :facing, lamba { |orientation| { :conditions => { :orientation => orientation } } } do | |
def group_by_elevation_index | |
group_by{|component| component.elevation_index - component.component_model.height + 1 } | |
end | |
end | |
def self.front_facing | |
self.facing "A" | |
end | |
def self.back_facing | |
self.facing "AB" | |
end | |
def self.left_facing | |
self.facing "AA" | |
end | |
def self.right_facing | |
self.facing "AC" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment