Class: Reactor::Link::TemporaryLink
- Inherits:
-
Object
- Object
- Reactor::Link::TemporaryLink
- Defined in:
- lib/reactor/link/temporary_link.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
Returns the value of attribute target.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #destination_object ⇒ Object
- #external? ⇒ Boolean
- #id ⇒ Object
-
#initialize(anything) ⇒ TemporaryLink
constructor
A new instance of TemporaryLink.
- #internal? ⇒ Boolean
Constructor Details
#initialize(anything) ⇒ TemporaryLink
Returns a new instance of TemporaryLink.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/reactor/link/temporary_link.rb', line 12 def initialize(anything) link_data = {} case anything when Hash link_data = anything when Integer link_data[:url] = RailsConnector::AbstractObj.find(anything).path else link_data[:url] = anything end self.url = link_data[:url] || link_data[:destination_object] if link_data[:search].present? self.url = "#{self.url}?#{link_data[:search]}" end if link_data[:fragment].present? self.url = "#{self.url}##{link_data[:fragment]}" end self.target = link_data[:target] if link_data.key?(:target) self.title = link_data[:title] if link_data.key?(:title) end |
Instance Attribute Details
#target ⇒ Object
Returns the value of attribute target.
7 8 9 |
# File 'lib/reactor/link/temporary_link.rb', line 7 def target @target end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/reactor/link/temporary_link.rb', line 6 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/reactor/link/temporary_link.rb', line 5 def url @url end |
Instance Method Details
#destination_object ⇒ Object
45 46 47 |
# File 'lib/reactor/link/temporary_link.rb', line 45 def destination_object @destination_object ||= RailsConnector::AbstractObj.find_by_path(url) end |
#external? ⇒ Boolean
9 |
# File 'lib/reactor/link/temporary_link.rb', line 9 def external? ; raise TypeError, "This link needs to be persisted to gain any meaningful information" ; end |
#id ⇒ Object
49 50 51 |
# File 'lib/reactor/link/temporary_link.rb', line 49 def id nil end |
#internal? ⇒ Boolean
10 |
# File 'lib/reactor/link/temporary_link.rb', line 10 def internal? ; false ; end |