Module: Gretel::Crumbs
- Extended by:
- Resettable
- Defined in:
- lib/gretel/crumbs.rb
Defined Under Namespace
Classes: Builder
Class Method Summary collapse
-
.breadcrumb_files ⇒ Object
List of breadcrumb configuration files.
-
.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.
49 50 51 |
# File 'lib/gretel/crumbs.rb', line 49 def Dir[*Gretel.] end |
.crumb_defined?(key) ⇒ Boolean
Returns true if a crumb with the given key has been set.
12 13 14 |
# File 'lib/gretel/crumbs.rb', line 12 def crumb_defined?(key) crumbs.has_key?(key) end |
.crumbs ⇒ Object
Returns a hash of all stored crumb blocks.
7 8 9 |
# File 'lib/gretel/crumbs.rb', line 7 def crumbs @crumbs ||= {} end |
.load_breadcrumbs ⇒ Object
Loads the breadcrumb configuration files.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gretel/crumbs.rb', line 17 def builder = Builder.new loaded_file_mtimes.clear .each do |file| builder.instance_eval open(file).read, file loaded_file_mtimes << File.mtime(file) end @crumbs = builder.crumbs @loaded = true end |
.loaded? ⇒ Boolean
Returns true if the breadcrumb configuration files have been loaded.
44 45 46 |
# File 'lib/gretel/crumbs.rb', line 44 def loaded? !!@loaded end |
.reload? ⇒ Boolean
Returns true if a breadcrumbs reload is needed based on configuration file changes.
36 37 38 39 40 41 |
# File 'lib/gretel/crumbs.rb', line 36 def reload? return true unless loaded? return false unless Gretel.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.
31 32 33 |
# File 'lib/gretel/crumbs.rb', line 31 def reload_if_needed if reload? end |