Module: DatGretel::Crumbs
- Extended by:
- Resettable
- Defined in:
- lib/dat_gretel/crumbs.rb
Class Method Summary collapse
-
.breadcrumb_files ⇒ Object
List of breadcrumb configuration files.
-
.crumb(key, &block) ⇒ Object
Stores the supplied block for later use.
-
.crumb_defined?(key) ⇒ Boolean
Returns true if a crumb with the given key has been set.
-
.crumbs ⇒ Object
Returns a hash of all stored crumb blocks.
-
.load_breadcrumbs ⇒ Object
Loads the breadcrumb configuration files.
-
.loaded? ⇒ Boolean
Returns true if the breadcrumb configuration files have been loaded.
-
.reload? ⇒ Boolean
Returns true if a breadcrumbs reload is needed based on configuration file changes.
-
.reload_if_needed ⇒ Object
Reloads the breadcrumb configuration files if they have changed.
Methods included from Resettable
Class Method Details
.breadcrumb_files ⇒ Object
List of breadcrumb configuration files.
53 54 55 |
# File 'lib/dat_gretel/crumbs.rb', line 53 def Dir[*DatGretel.] end |
.crumb(key, &block) ⇒ Object
Stores the supplied block for later use.
7 8 9 |
# File 'lib/dat_gretel/crumbs.rb', line 7 def crumb(key, &block) crumbs[key] = block end |
.crumb_defined?(key) ⇒ Boolean
Returns true if a crumb with the given key has been set.
17 18 19 |
# File 'lib/dat_gretel/crumbs.rb', line 17 def crumb_defined?(key) crumbs.has_key?(key) end |
.crumbs ⇒ Object
Returns a hash of all stored crumb blocks.
12 13 14 |
# File 'lib/dat_gretel/crumbs.rb', line 12 def crumbs @crumbs ||= {} end |
.load_breadcrumbs ⇒ Object
Loads the breadcrumb configuration files.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dat_gretel/crumbs.rb', line 22 def @crumbs = {} loaded_file_mtimes.clear .each do |file| instance_eval open(file).read, file loaded_file_mtimes << File.mtime(file) end @loaded = true end |
.loaded? ⇒ Boolean
Returns true if the breadcrumb configuration files have been loaded.
48 49 50 |
# File 'lib/dat_gretel/crumbs.rb', line 48 def loaded? !!@loaded if defined? @loaded end |
.reload? ⇒ Boolean
Returns true if a breadcrumbs reload is needed based on configuration file changes.
40 41 42 43 44 45 |
# File 'lib/dat_gretel/crumbs.rb', line 40 def reload? return true unless loaded? return false unless DatGretel.reload_environments.include?(Rails.env) loaded_file_mtimes != .map { |file| File.mtime(file) } end |
.reload_if_needed ⇒ Object
Reloads the breadcrumb configuration files if they have changed.
35 36 37 |
# File 'lib/dat_gretel/crumbs.rb', line 35 def reload_if_needed if reload? end |