Create Legislation Process Phase and Publication classes to enclose enabled?/started?/open? logic
This commit is contained in:
22
app/models/legislation/process/phase.rb
Normal file
22
app/models/legislation/process/phase.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Legislation::Process::Phase
|
||||
|
||||
def initialize(start_date, end_date)
|
||||
@start_date = start_date
|
||||
@end_date = end_date
|
||||
end
|
||||
|
||||
def enabled?
|
||||
@start_date.present? && @end_date.present?
|
||||
end
|
||||
|
||||
def started?
|
||||
enabled? && Date.current >= @start_date
|
||||
end
|
||||
|
||||
def open?
|
||||
started? && Date.current <= @end_date
|
||||
end
|
||||
|
||||
end
|
||||
21
app/models/legislation/process/publication.rb
Normal file
21
app/models/legislation/process/publication.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Legislation::Process::Publication
|
||||
|
||||
def initialize(publication_date)
|
||||
@publication_date = publication_date
|
||||
end
|
||||
|
||||
def enabled?
|
||||
@publication_date.present?
|
||||
end
|
||||
|
||||
def started?
|
||||
enabled? && Date.current >= @publication_date
|
||||
end
|
||||
|
||||
def open?
|
||||
started?
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user