class Buoys::Loader
Public Class Methods
buoy(key, &block)
click to toggle source
buoy :account do
link 'Account', account_path
end
buoy :account_edit do |account|
link 'Account Edit', edit_account_path(account) pre_buoy :account
end
# File lib/buoys/loader.rb, line 15 def buoy(key, &block) buoys[key] = block end
Also aliased as: crumb
buoy_files()
click to toggle source
# File lib/buoys/loader.rb, line 40 def buoy_files Dir[*Buoys.buoy_file_paths] end
buoys()
click to toggle source
# File lib/buoys/loader.rb, line 20 def buoys @buoys ||= {} end
load_buoys_files()
click to toggle source
# File lib/buoys/loader.rb, line 28 def load_buoys_files return unless need_reload? buoys.clear loaded_times.clear buoy_files.each do |file| instance_eval File.read(file), file loaded_times << File.mtime(file) end end
loaded_times()
click to toggle source
# File lib/buoys/loader.rb, line 24 def loaded_times @loaded_times ||= [] end
need_reload?()
click to toggle source
# File lib/buoys/loader.rb, line 44 def need_reload? return true if buoys.empty? Rails.env.development? && loaded_times != buoy_files.map {|f| File.mtime(f) } end