Sha256: 19cba000b285f08a015dc46546d193ecf9a854f2df42d26e560eefd484f05cbf

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

class Dependency < ActiveRecord::Base
	has_many :devices,	:class_name => "ControllerDevice",		:dependent => :destroy
	has_many :logics,	:class_name => "ControllerLogic",		:dependent => :destroy
	has_many :services,	:class_name => "ControllerHttpService",	:dependent => :destroy
	
	has_many :settings,	:as => :object,		:dependent => :destroy
	
	scope :for_controller, lambda {|controller|
		includes(:controller_devices, :controller_logics, :controller_http_services)
		.where("(controller_devices.dependency_id = dependencies.id AND controller_devices.control_system_id = ?) OR (controller_logics.dependency_id = dependencies.id AND controller_logics.control_system_id = ?) OR (controller_http_services.dependency_id = dependencies.id AND controller_http_services.control_system_id = ?)", controller.id, controller.id, controller.id)
	}
	
	
	protected
	
	
	validates_presence_of :classname, :module_name, :actual_name
	validates_uniqueness_of :classname
	validates_uniqueness_of :actual_name
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
automate-em-0.0.4 app/models/dependency.rb
automate-em-0.0.3 app/models/dependency.rb