Class: RoarExtensions::LinkPresenter
- Inherits:
-
Object
- Object
- RoarExtensions::LinkPresenter
- Defined in:
- lib/roar_extensions/link_presenter.rb
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#rel ⇒ Object
readonly
Returns the value of attribute rel.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(rel, href, title = nil) ⇒ LinkPresenter
constructor
A new instance of LinkPresenter.
- #to_hash(*args) ⇒ Object (also: #as_json)
Constructor Details
#initialize(rel, href, title = nil) ⇒ LinkPresenter
Returns a new instance of LinkPresenter.
4 5 6 7 8 |
# File 'lib/roar_extensions/link_presenter.rb', line 4 def initialize(rel, href, title = nil) @href = href @rel = rel @title = title end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
2 3 4 |
# File 'lib/roar_extensions/link_presenter.rb', line 2 def href @href end |
#rel ⇒ Object (readonly)
Returns the value of attribute rel.
2 3 4 |
# File 'lib/roar_extensions/link_presenter.rb', line 2 def rel @rel end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'lib/roar_extensions/link_presenter.rb', line 2 def title @title end |
Instance Method Details
#==(other) ⇒ Object
10 11 12 13 14 |
# File 'lib/roar_extensions/link_presenter.rb', line 10 def ==(other) href == other.href && rel == other.rel && title == other.title end |
#to_hash(*args) ⇒ Object Also known as: as_json
16 17 18 19 20 21 22 23 |
# File 'lib/roar_extensions/link_presenter.rb', line 16 def to_hash(*args) { rel => { 'href' => href, 'title' => title }.delete_if {|k,v| v.nil? || v.empty?} } end |