Class: Sipity::Decorators::LinkedAction

Inherits:
Object
  • Object
show all
Defined in:
app/decorators/sipity/decorators/linked_action.rb

Overview

Responsible for rendering a link to a given action

@note: I don't envision this object keeping the same initialization. Its

very naive and may not provide adequate information for alternate
rendering options (i.e. #render method)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, path:, html_options: {}) ⇒ LinkedAction


10
11
12
# File 'app/decorators/sipity/decorators/linked_action.rb', line 10

def initialize(label:, path:, html_options: {})
  @label, @path, @html_options = label, path, html_options
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options


9
10
11
# File 'app/decorators/sipity/decorators/linked_action.rb', line 9

def html_options
  @html_options
end

#labelObject (readonly)

Returns the value of attribute label


9
10
11
# File 'app/decorators/sipity/decorators/linked_action.rb', line 9

def label
  @label
end

#pathObject (readonly)

Returns the value of attribute path


9
10
11
# File 'app/decorators/sipity/decorators/linked_action.rb', line 9

def path
  @path
end

Instance Method Details

#render(template) ⇒ Object

@todo: Should we translate the label? If so, we need more information

regarding the context of the link (i.e. the entity to which this was
associated).

17
18
19
# File 'app/decorators/sipity/decorators/linked_action.rb', line 17

def render(template)
  template.link_to(label, path, html_options)
end