Module: Gretel

Extended by:
Resettable
Defined in:
lib/gretel.rb,
lib/gretel/link.rb,
lib/gretel/crumb.rb,
lib/gretel/crumbs.rb,
lib/gretel/railtie.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, Railtie, Renderer

Constant Summary collapse

VERSION =
"5.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”].



32
33
34
# File 'lib/gretel.rb', line 32

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.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gretel.rb', line 12

def breadcrumb_paths
  @breadcrumb_paths ||= begin
    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.



27
28
29
# File 'lib/gretel.rb', line 27

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



51
52
53
# File 'lib/gretel.rb', line 51

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 }


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

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