Sha256: a98b4f5ef6e2c01dece05b87e246f1eb5f90f36aa103a1df58d07186409e4daa

Contents?: true

Size: 973 Bytes

Versions: 5

Compression:

Stored size: 973 Bytes

Contents

# frozen_string_literal: true

require "stimulus_reflex/installer"

if application_record_path.exist?
  lines = application_record_path.readlines

  if !lines.index { |line| line =~ /^\s*include CableReady::Updatable/ }
    proceed = if options.key? "updatable"
      options["updatable"]
    else
      !no?("✨ Include CableReady::Updatable in Active Record model classes? (Y/n)")
    end

    unless proceed
      complete_step :updatable

      puts "⏩ Skipping."
      return
    end

    index = lines.index { |line| line.include?("class ApplicationRecord < ActiveRecord::Base") }
    lines.insert index + 1, "  include CableReady::Updatable\n"
    application_record_path.write lines.join

    say "✅ included CableReady::Updatable in ApplicationRecord"
  else
    say "⏩ CableReady::Updatable has already been included in Active Record model classes. Skipping."
  end
else
  say "⏩ ApplicationRecord doesn't exist. Skipping."
end

complete_step :updatable

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stimulus_reflex-3.5.0.rc4 lib/install/updatable.rb
stimulus_reflex-3.5.0.rc3 lib/install/updatable.rb
stimulus_reflex-3.5.0.rc2 lib/install/updatable.rb
stimulus_reflex-3.5.0.rc1 lib/install/updatable.rb
stimulus_reflex-3.5.0.pre10 lib/install/updatable.rb