Module: Gretel

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

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"3.0.6"

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”].



53
54
55
# File 'lib/gretel.rb', line 53

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
# File 'lib/gretel.rb', line 17

def breadcrumb_paths
  @breadcrumb_paths ||= begin
    engine_roots = Rails::Application::Railties.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.



30
31
32
# File 'lib/gretel.rb', line 30

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 (Gretel)

    the object that the method was called on



72
73
74
# File 'lib/gretel.rb', line 72

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 }


60
61
62
# File 'lib/gretel.rb', line 60

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

.show_deprecation_warning(message) ⇒ Object

Shows a deprecation warning.



45
46
47
48
49
50
# File 'lib/gretel.rb', line 45

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.



40
41
42
# File 'lib/gretel.rb', line 40

def suppress_deprecation_warnings=(value)
  @suppress_deprecation_warnings = value
end

.suppress_deprecation_warnings?Boolean

Whether to suppress deprecation warnings.

Returns:

  • (Boolean)


35
36
37
# File 'lib/gretel.rb', line 35

def suppress_deprecation_warnings?
  !!@suppress_deprecation_warnings
end