Module: RailsMarkup::ToolbarSource

Defined in:
lib/rails_markup/toolbar_source.rb

Constant Summary collapse

DIR =
File.expand_path("../../app/assets/javascripts/rails_markup/toolbar", __dir__)

Class Method Summary collapse

Class Method Details

.buildObject



16
17
18
# File 'lib/rails_markup/toolbar_source.rb', line 16

def self.build
  Dir.glob(File.join(DIR, "*.js")).sort.map { |file| File.read(file) }.join("\n")
end

.reset!Object



20
21
22
# File 'lib/rails_markup/toolbar_source.rb', line 20

def self.reset!
  @script = nil
end

.scriptObject



7
8
9
10
11
12
13
14
# File 'lib/rails_markup/toolbar_source.rb', line 7

def self.script
  # Re-read every call in development so editing a toolbar/ module shows up
  # without a restart (matches the old single-file File.read). Memoize only
  # where the source can't change under a running process.
  return build if defined?(Rails) && Rails.env.development?

  @script ||= build
end