Class: Mariner::Store

Inherits:
Abyss::DeepStore
  • Object
show all
Defined in:
lib/mariner/store.rb

Overview

Public: Uses the Abyss library to provide arbitrarily-deep sets of navigation groups / urls. Think of this as the group when defining nav trees.

Examples:

Mariner.configure do

  a_group do         # <= This effectivly creates a new Mariner::Store, ...
    root_path "Home" # <= and this creates a new Mariner::Url within said store.
  end

end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStore

Public: Sets virtual to false by default and defers to ::Abyss::DeepStore for initialization.



32
33
34
35
# File 'lib/mariner/store.rb', line 32

def initialize(*)
  @virtual = false
  super
end

Instance Attribute Details

#virtualObject Also known as: virtual?

Public: If the group is virtual, the rendering strategy shouldn’t generate any output around its nested configurations when. e.g. The UnorderedListRenderer doesn’t generate ‘ul` or `li` tags when the target group is virtual.



26
27
28
# File 'lib/mariner/store.rb', line 26

def virtual
  @virtual
end

Instance Method Details

#assign(method_name, values) ⇒ Object

Public: Abstract method override - overrides ::Abyss::DeepStore#assign to store Urls. This is only called when NOT dealing with a nested group.

e.g.:

Mariner.configure do

  a_group do
    root_path "Home" # <= #assign gets called.
  end

end

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
# File 'lib/mariner/store.rb', line 51

def assign(method_name, values)
  raise ArgumentError, "Wrong number of values specified (#{values.size} for <= 2)" if values.size > 2

  values[1] ||= {} # link options
  title, options = values
  self.configurations[method_name] = Url.new(method_name, title, options)
end

#render(rendering_strategy = ) ⇒ Object

Public: Uses a rendering strategy to render itself.

rendering_strategy - The rendering strategy to use when rendering.

Examples:

Mariner.configuration #=> An Mariner::Store instance

Mariner.configuration.render
Mariner.configuration.render(SomeRenderingStrategy.new)


70
71
72
# File 'lib/mariner/store.rb', line 70

def render(rendering_strategy=Mariner.rendering_strategies[:default])
  rendering_strategy.factory(:group, self).render
end