Project

General

Profile

« Previous | Next » 

Revision bb3572ff

Added by Daniel Lobato Garcia over 8 years ago

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.

View differences:

app/models/nic/base.rb
validate :validate_host_location, :if => Proc.new { |nic| SETTINGS[:locations_enabled] && nic.subnet.present? }
validate :validate_host_organization, :if => Proc.new { |nic| SETTINGS[:organizations_enabled] && nic.subnet.present? }
scope :bootable, lambda { where(:type => "Nic::Bootable") }
scope :bmc, lambda { where(:type => "Nic::BMC") }
scope :bonds, lambda { where(:type => "Nic::Bond") }
scope :interfaces, lambda { where(:type => "Nic::Interface") }
scope :managed, lambda { where(:type => "Nic::Managed") }
scope :virtual, lambda { where(:virtual => true) }
scope :physical, lambda { where(:virtual => false) }
scope :is_managed, lambda { where(:managed => true) }
scope :primary, lambda { { :conditions => { :primary => true } } }
scope :provision, lambda { { :conditions => { :provision => true } } }
scope :bootable, -> { where(:type => "Nic::Bootable") }
scope :bmc, -> { where(:type => "Nic::BMC") }
scope :bonds, -> { where(:type => "Nic::Bond") }
scope :interfaces, -> { where(:type => "Nic::Interface") }
scope :managed, -> { where(:type => "Nic::Managed") }
scope :virtual, -> { where(:virtual => true) }
scope :physical, -> { where(:virtual => false) }
scope :is_managed, -> { where(:managed => true) }
scope :primary, -> { { :conditions => { :primary => true } } }
scope :provision, -> { { :conditions => { :provision => true } } }
belongs_to :subnet
belongs_to :domain, :counter_cache => 'hosts_count'

Also available in: Unified diff