Class: RoarExtensions::LinkPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/roar_extensions/link_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hrefObject (readonly)

Returns the value of attribute href.



2
3
4
# File 'lib/roar_extensions/link_presenter.rb', line 2

def href
  @href
end

#relObject (readonly)

Returns the value of attribute rel.



2
3
4
# File 'lib/roar_extensions/link_presenter.rb', line 2

def rel
  @rel
end

#titleObject (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