app/models/spud_calendar.rb in tb_events-1.2.0.beta1 vs app/models/spud_calendar.rb in tb_events-1.3.0
- old
+ new
@@ -1,34 +1,32 @@
class SpudCalendar < ActiveRecord::Base
- has_many :spud_calendar_events, :dependent => :destroy
+ has_many :spud_calendar_events, dependent: :destroy
validates_presence_of :title
- validates :identifier, :presence => true, :uniqueness => true
+ validates :identifier, presence: true, uniqueness: true
before_validation :set_identifier
def self.with_identifier(identifier)
- where(:identifier => identifier).first
+ where(identifier: identifier).first
end
def color
- modulo = (self.id-1) % COLORS.length
- return COLORS[modulo]
+ modulo = (id - 1) % COLORS.length
+ COLORS[modulo]
end
- COLORS = [
- '4D854B',
- 'f89406',
- 'b94a48',
- '3a87ad',
- '999999',
- '333333'
- ]
+ COLORS = %w(
+ 4D854B
+ f89406
+ b94a48
+ 3a87ad
+ 999999
+ 333333)
-private
+ private
def set_identifier
if identifier.nil? && title.present?
self.identifier = title.parameterize.underscore
end
end
-
end