Class: Roar::Hypermedia::Hyperlink

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/roar/hypermedia.rb

Overview

An abstract hypermedia link with arbitrary attributes.

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Hyperlink

Returns a new instance of Hyperlink.



126
127
128
# File 'lib/roar/hypermedia.rb', line 126

def initialize(attrs={})
  @attrs = attributes!(attrs)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object (private)



141
142
143
# File 'lib/roar/hypermedia.rb', line 141

def method_missing(name)
  @attrs[name.to_s]
end

Instance Method Details

#merge!(attrs) ⇒ Object

Only way to write to Hyperlink after creation.



136
137
138
# File 'lib/roar/hypermedia.rb', line 136

def merge!(attrs)
  @attrs.merge!(attributes!(attrs))
end

#replace(attrs) ⇒ Object

makes it work with Hash::Hash.



130
131
132
133
# File 'lib/roar/hypermedia.rb', line 130

def replace(attrs) # makes it work with Hash::Hash.
  @attrs = attributes!(attrs)
  self
end