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.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/reactor/link/temporary_link.rb', line 15 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] self.url = "#{url}?#{link_data[:search]}" if link_data[:search].present? self.url = "#{url}##{link_data[:fragment]}" if link_data[:fragment].present? 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.
5 6 7 |
# File 'lib/reactor/link/temporary_link.rb', line 5 def target @target end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/reactor/link/temporary_link.rb', line 5 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/reactor/link/temporary_link.rb', line 4 def url @url end |
Instance Method Details
#destination_object ⇒ Object
44 45 46 |
# File 'lib/reactor/link/temporary_link.rb', line 44 def destination_object @destination_object ||= RailsConnector::AbstractObj.find_by_path(url) end |
#external? ⇒ Boolean
7 8 9 |
# File 'lib/reactor/link/temporary_link.rb', line 7 def external? raise TypeError, "This link needs to be persisted to gain any meaningful information" end |
#id ⇒ Object
48 49 50 |
# File 'lib/reactor/link/temporary_link.rb', line 48 def id nil end |
#internal? ⇒ Boolean
11 12 13 |
# File 'lib/reactor/link/temporary_link.rb', line 11 def internal? false end |