Sha256: 75ccc2ade3bcb1c7153f0d5c564420832adf1e027edd44ce62da77520f5a0afe
Contents?: true
Size: 1.74 KB
Versions: 3
Compression:
Stored size: 1.74 KB
Contents
module Gretel module Crumbs class << self # Stores the supplied block for later use. def crumb(key, &block) crumbs[key] = block end # Returns an array of all stored crumb blocks. def crumbs @crumbs ||= {} end # Returns true if a crumb with the given key has been set. def crumb_defined?(key) crumbs.has_key?(key) end # Loads the breadcrumb configuration files. def load_breadcrumbs @crumbs = {} # Deprecated in v2.1.0. instance_eval &deprecated_breadcrumbs_block loaded_file_mtimes.clear breadcrumb_files.each do |file| instance_eval open(file).read, file loaded_file_mtimes << File.mtime(file) end @loaded = true end # Reloads the breadcrumb configuration files if they have changed. def reload_if_needed load_breadcrumbs if reload? end # Returns true if a breadcrumbs reload is needed based on configuration file changes. def reload? return true unless loaded? return false unless Gretel.reload_environments.include?(Rails.env) loaded_file_mtimes != breadcrumb_files.map { |file| File.mtime(file) } end # Returns true if the breadcrumb configuration files have been loaded. def loaded? !!@loaded end # List of breadcrumb configuration files. def breadcrumb_files Dir[*Gretel.breadcrumb_paths] end # Resets all changes made to +Gretel::Crumbs+. Used for testing. def reset! instance_variables.each { |var| remove_instance_variable var } end private def loaded_file_mtimes @loaded_file_mtimes ||= [] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gretel-2.2.0.rc2 | lib/gretel/crumbs.rb |
gretel-2.2.0.rc1 | lib/gretel/crumbs.rb |
gretel-2.1.0 | lib/gretel/crumbs.rb |