From 1e1346e5e49b557d3344ea07477cf475f27acb0f Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Thu, 25 May 2017 11:27:28 +0100 Subject: [PATCH] Make Section#editions private 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. --- app/models/manual.rb | 2 +- app/models/section.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/manual.rb b/app/models/manual.rb index e9171bd7e..55faaef27 100644 --- a/app/models/manual.rb +++ b/app/models/manual.rb @@ -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) diff --git a/app/models/section.rb b/app/models/section.rb index 8af08c4f2..d28bfab42 100644 --- a/app/models/section.rb +++ b/app/models/section.rb @@ -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) @@ -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