Module: DatGretel

Extended by:
Resettable
Defined in:
lib/dat_gretel.rb,
lib/dat_gretel/link.rb,
lib/dat_gretel/crumb.rb,
lib/dat_gretel/crumbs.rb,
lib/dat_gretel/version.rb,
lib/dat_gretel/renderer.rb,
lib/dat_gretel/resettable.rb,
lib/dat_gretel/view_helpers.rb,
lib/generators/dat_gretel/install_generator.rb

Defined Under Namespace

Modules: Crumbs, Resettable, ViewHelpers Classes: Crumb, InstallGenerator, Link, Renderer

Constant Summary collapse

VERSION =
"4.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Resettable

reset!

Class Attribute Details

.reload_environmentsObject

Array of Rails environment names with automatic configuration reload. Default is [“development”].



57
58
59
# File 'lib/dat_gretel.rb', line 57

def reload_environments
  @reload_environments ||= ["development"]
end

Class Method Details

Returns the path from with breadcrumbs are loaded. Default is config/breadcrumbs.rb in the app and all loaded engines. Breadcrumbs set in the app will override breadcrumbs set in engines.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dat_gretel.rb', line 17

def breadcrumb_paths
  @breadcrumb_paths ||= begin
    engines = Rails::Engine::Railties.respond_to?(:engines) ?
      Rails::Engine::Railties.engines :
      Rails::Engine.subclasses.map(&:instance)

    engine_roots = engines.map { |e| e.config.root }
    
    [*engine_roots, Rails.root].map do |root|
      [root.join("config", "breadcrumbs.rb"),
       root.join("config", "breadcrumbs", "**", "*.rb"),
       root.join("app", "views", "breadcrumbs", "**", "*.rb")]
    end.flatten
  end
end

Sets the path from with breadcrumbs are loaded. Default is config/breadcrumbs.rb.



34
35
36
# File 'lib/dat_gretel.rb', line 34

def breadcrumb_paths=(paths)
  @breadcrumb_paths = paths
end

.configure {|_self| ... } ⇒ Object

Yields this Gretel to be configured.

Gretel.configure do |config|
  config.reload_environments << "staging"
end

Yields:

  • (_self)

Yield Parameters:

  • _self (DatGretel)

    the object that the method was called on



76
77
78
# File 'lib/dat_gretel.rb', line 76

def configure
  yield self
end

.register_style(style, options) ⇒ Object

Registers a style for later use.

Gretel.register_style :ul, { container_tag: :ul, fragment_tag: :li }


64
65
66
# File 'lib/dat_gretel.rb', line 64

def register_style(style, options)
  DatGretel::Renderer.register_style style, options
end

.show_deprecation_warning(message) ⇒ Object

Shows a deprecation warning.



49
50
51
52
53
54
# File 'lib/dat_gretel.rb', line 49

def show_deprecation_warning(message)
  return if suppress_deprecation_warnings?
  message = "[Gretel] #{message}"
  puts message
  Rails.logger.warn message
end

.suppress_deprecation_warnings=(value) ⇒ Object

Sets whether to suppress deprecation warnings.



44
45
46
# File 'lib/dat_gretel.rb', line 44

def suppress_deprecation_warnings=(value)
  @suppress_deprecation_warnings = value
end

.suppress_deprecation_warnings?Boolean

Whether to suppress deprecation warnings.

Returns:

  • (Boolean)


39
40
41
# File 'lib/dat_gretel.rb', line 39

def suppress_deprecation_warnings?
  !!@suppress_deprecation_warnings if defined? @suppress_deprecation_warnings
end