Revision bb3572ff
Added by Daniel Lobato Garcia over 8 years ago
app/models/host/base.rb | ||
---|---|---|
validate :host_has_required_interfaces
|
||
validate :uniq_interfaces_identifiers
|
||
|
||
default_scope lambda {
|
||
where(taxonomy_conditions)
|
||
}
|
||
default_scope -> { where(taxonomy_conditions) }
|
||
|
||
def self.taxonomy_conditions
|
||
org = Organization.expand(Organization.current) if SETTINGS[:organizations_enabled]
|
||
... | ... | |
conditions
|
||
end
|
||
|
||
scope :no_location, lambda { where(:location_id => nil) }
|
||
scope :no_organization, lambda { where(:organization_id => nil) }
|
||
scope :no_location, -> { where(:location_id => nil) }
|
||
scope :no_organization, -> { where(:organization_id => nil) }
|
||
|
||
# primary interface is mandatory because of delegated methods so we build it if it's missing
|
||
# similar for provision interface
|
Also available in: Unified diff
Refs #3809 - Stabby lambda syntax for oneliners
I started by spotting log.rb which didn't have a lambda wrapping its
default scope, as needed by Rails 4. Since the style guide and most
Rails 4 documents used the stabby lambda, I turned on the cop so that we
use it everywhere there's a oneliner lambda.