Class: ForemanPuppet::EnvironmentClass
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ForemanPuppet::EnvironmentClass
- Defined in:
- app/models/foreman_puppet/environment_class.rb
Class Method Summary collapse
-
.is_in_any_environment(puppetclass, puppetclass_lookup_key) ⇒ Object
TODO: move these into scopes?.
- .key_in_environment(env, puppetclass, puppetclass_lookup_key) ⇒ Object
Instance Method Summary collapse
Class Method Details
.is_in_any_environment(puppetclass, puppetclass_lookup_key) ⇒ Object
TODO: move these into scopes?
28 29 30 |
# File 'app/models/foreman_puppet/environment_class.rb', line 28 def self.is_in_any_environment(puppetclass, puppetclass_lookup_key) EnvironmentClass.where(puppetclass_id: puppetclass, puppetclass_lookup_key_id: puppetclass_lookup_key).any? end |
.key_in_environment(env, puppetclass, puppetclass_lookup_key) ⇒ Object
32 33 34 |
# File 'app/models/foreman_puppet/environment_class.rb', line 32 def self.key_in_environment(env, puppetclass, puppetclass_lookup_key) EnvironmentClass.find_by(environment_id: env, puppetclass_id: puppetclass, puppetclass_lookup_key_id: puppetclass_lookup_key) end |
Instance Method Details
#delete_orphaned_lookup_keys ⇒ Object
36 37 38 |
# File 'app/models/foreman_puppet/environment_class.rb', line 36 def delete_orphaned_lookup_keys puppetclass_lookup_key.destroy if puppetclass_lookup_key.present? && puppetclass_lookup_key.environment_classes.empty? end |