Skip to content

Commit

Permalink
Make Section#editions private
Browse files Browse the repository at this point in the history
I'm working toward removing the Section#editions method completely and
making it private ensures that nothing other than `Section` is using it.

Note that I've had to change the `Manual#destroy` method so that it's
calling `Section#all_editions` instead of `#editions`. This fixes issue
 #1116.
  • Loading branch information
chrisroos committed May 25, 2017
1 parent c34b576 commit 1e1346e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/manual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def publication_logs

def destroy
sections.each do |section|
section.editions.each(&:destroy)
section.all_editions.each(&:destroy)
end

manual_record = ManualRecord.find_by(manual_id: id)
Expand Down
4 changes: 2 additions & 2 deletions app/models/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.find(manual, section_uuid, published: false)

def_delegators :latest_edition, :title, :slug, :summary, :body, :updated_at, :version_number, :change_note, :minor_update

attr_reader :uuid, :editions, :latest_edition
attr_reader :uuid, :latest_edition

def initialize(manual:, uuid:, editions:)
@slug_generator = SlugGenerator.new(prefix: manual.slug)
Expand Down Expand Up @@ -173,7 +173,7 @@ def all_editions

private

attr_reader :slug_generator
attr_reader :slug_generator, :editions

def published_edition
most_recent_non_draft = editions.reject(&:draft?).last
Expand Down

0 comments on commit 1e1346e

Please sign in to comment.