Class: Reactor::Link::TemporaryLink

Inherits:
Object
  • Object
show all
Defined in:
lib/reactor/link/temporary_link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#targetObject

Returns the value of attribute target.



7
8
9
# File 'lib/reactor/link/temporary_link.rb', line 7

def target
  @target
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/reactor/link/temporary_link.rb', line 6

def title
  @title
end

#urlObject

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_objectObject



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

Returns:

  • (Boolean)

Raises:

  • (TypeError)


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

#idObject



49
50
51
# File 'lib/reactor/link/temporary_link.rb', line 49

def id
  nil
end

#internal?Boolean

Returns:

  • (Boolean)


10
# File 'lib/reactor/link/temporary_link.rb', line 10

def internal? ; false ; end