Class: Mariner::Url
- Inherits:
-
Object
- Object
- Mariner::Url
- Defined in:
- lib/mariner/url.rb
Overview
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#href ⇒ Object
Public: Calls the Rails route helper method to get its href.
-
#initialize(name, title, options = {}) ⇒ Url
constructor
Public: Create a new Url.
-
#render(rendering_strategy = Mariner.rendering_strategies[:default]) ⇒ Object
Public: Renders itself through a rendering strategy.
Constructor Details
#initialize(name, title, options = {}) ⇒ Url
Public: Create a new Url
name - The method name that corresponds to a Rails route helper title - The text that should be rendered to represent a url. options - Any link options that should be present. Used by the
renderer (default: {})
24 25 26 |
# File 'lib/mariner/url.rb', line 24 def initialize(name, title, ={}) @name, @title, @options = name, title, end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/mariner/url.rb', line 15 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/mariner/url.rb', line 15 def @options end |
#title ⇒ Object
Returns the value of attribute title.
15 16 17 |
# File 'lib/mariner/url.rb', line 15 def title @title end |
Instance Method Details
#href ⇒ Object
Public: Calls the Rails route helper method to get its href.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mariner/url.rb', line 39 def href begin # The link's name should be the method name # for a rails route helper. We're including the route # helpers in an initializer, so this will only fail if # the route is undefined. # send(name) rescue NoMethodError => e raise ::Mariner::Errors::InvalidUrlHelperMethod.new(name) end end |
#render(rendering_strategy = Mariner.rendering_strategies[:default]) ⇒ Object
Public: Renders itself through a rendering strategy.
rendering_strategy - The rendering strategy to use. Must respond to
#render (default: UnorderedListRenderer.new)
33 34 35 |
# File 'lib/mariner/url.rb', line 33 def render(rendering_strategy=Mariner.rendering_strategies[:default]) rendering_strategy.factory(:item, self).render end |