Class: Reactor::Cm::Link
- Inherits:
-
Object
- Object
- Reactor::Cm::Link
- Defined in:
- lib/reactor/cm/link.rb
Instance Attribute Summary collapse
-
#dest_obj_id ⇒ Object
Returns the value of attribute dest_obj_id.
-
#dest_url ⇒ Object
Returns the value of attribute dest_url.
-
#link_id ⇒ Object
readonly
Returns the value of attribute link_id.
-
#position ⇒ Object
Returns the value of attribute position.
-
#target ⇒ Object
Returns the value of attribute target.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .create(content, attr, url, title = nil) ⇒ Object
- .create_inside(obj, attr, url, title = nil) ⇒ Object
- .exists?(id) ⇒ Boolean
- .get(id) ⇒ Object
Instance Method Summary collapse
- #delete! ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #is_external? ⇒ Boolean
- #is_internal? ⇒ Boolean
- #save! ⇒ Object
Instance Attribute Details
#dest_obj_id ⇒ Object
Returns the value of attribute dest_obj_id.
5 6 7 |
# File 'lib/reactor/cm/link.rb', line 5 def dest_obj_id @dest_obj_id end |
#dest_url ⇒ Object
Returns the value of attribute dest_url.
5 6 7 |
# File 'lib/reactor/cm/link.rb', line 5 def dest_url @dest_url end |
#link_id ⇒ Object (readonly)
Returns the value of attribute link_id.
5 6 7 |
# File 'lib/reactor/cm/link.rb', line 5 def link_id @link_id end |
#position ⇒ Object
Returns the value of attribute position.
6 7 8 |
# File 'lib/reactor/cm/link.rb', line 6 def position @position end |
#target ⇒ Object
Returns the value of attribute target.
6 7 8 |
# File 'lib/reactor/cm/link.rb', line 6 def target @target end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/reactor/cm/link.rb', line 6 def title @title end |
Class Method Details
.create(content, attr, url, title = nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/reactor/cm/link.rb', line 24 def self.create(content, attr, url, title=nil) link = Link.new link.send(:create, content, attr, url, title) link end |
.create_inside(obj, attr, url, title = nil) ⇒ Object
20 21 22 |
# File 'lib/reactor/cm/link.rb', line 20 def self.create_inside(obj, attr, url, title=nil) create(obj.edited_content, attr, url, title) end |
.exists?(id) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/reactor/cm/link.rb', line 8 def self.exists?(id) return !Link.get(id).nil? rescue XmlRequestError => e return false end |
.get(id) ⇒ Object
14 15 16 17 18 |
# File 'lib/reactor/cm/link.rb', line 14 def self.get(id) link = Link.new link.send(:get,id) link end |
Instance Method Details
#delete! ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/reactor/cm/link.rb', line 74 def delete! request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, 'id', @link_id) xml.tag!("#{base_name}-delete") end response = request.execute! end |
#eql?(other) ⇒ Boolean
70 71 72 |
# File 'lib/reactor/cm/link.rb', line 70 def eql?(other) self.link_id == other.link_id end |
#hash ⇒ Object
63 64 65 66 67 |
# File 'lib/reactor/cm/link.rb', line 63 def hash # yes, to_s.to_is is neccesary, # because self.link_id is of type REXML::Text for the most of the time self.link_id.to_s.to_i end |
#is_external? ⇒ Boolean
30 31 32 |
# File 'lib/reactor/cm/link.rb', line 30 def is_external? @is_external == true end |
#is_internal? ⇒ Boolean
34 35 36 |
# File 'lib/reactor/cm/link.rb', line 34 def is_internal? !is_external? end |
#save! ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/reactor/cm/link.rb', line 50 def save! request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, 'id', @link_id) xml.set_tag!(base_name) do xml.tag!('target', @target) if @target xml.tag!('title', @title) if @title xml.tag!('destinationUrl', @dest_url) if @dest_url xml.tag!('position', @position) if @position end end response = request.execute! end |