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, target = nil) ⇒ Object
- .create_inside(obj, attr, url, title = nil, target = 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.
4 5 6 |
# File 'lib/reactor/cm/link.rb', line 4 def dest_obj_id @dest_obj_id end |
#dest_url ⇒ Object
Returns the value of attribute dest_url.
4 5 6 |
# File 'lib/reactor/cm/link.rb', line 4 def dest_url @dest_url end |
#link_id ⇒ Object (readonly)
Returns the value of attribute link_id.
4 5 6 |
# File 'lib/reactor/cm/link.rb', line 4 def link_id @link_id end |
#position ⇒ Object
Returns the value of attribute position.
5 6 7 |
# File 'lib/reactor/cm/link.rb', line 5 def position @position end |
#target ⇒ Object
Returns the value of attribute target.
5 6 7 |
# File 'lib/reactor/cm/link.rb', line 5 def target @target end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/reactor/cm/link.rb', line 5 def title @title end |
Class Method Details
.create(content, attr, url, title = nil, target = nil) ⇒ Object
23 24 25 26 27 |
# File 'lib/reactor/cm/link.rb', line 23 def self.create(content, attr, url, title = nil, target = nil) link = Link.new link.send(:create, content, attr, url, title, target) link end |
.create_inside(obj, attr, url, title = nil, target = nil) ⇒ Object
19 20 21 |
# File 'lib/reactor/cm/link.rb', line 19 def self.create_inside(obj, attr, url, title = nil, target = nil) create(obj.edited_content, attr, url, title, target) end |
.exists?(id) ⇒ Boolean
7 8 9 10 11 |
# File 'lib/reactor/cm/link.rb', line 7 def self.exists?(id) !Link.get(id).nil? rescue XmlRequestError false end |
.get(id) ⇒ Object
13 14 15 16 17 |
# File 'lib/reactor/cm/link.rb', line 13 def self.get(id) link = Link.new link.send(:get, id) link end |
Instance Method Details
#delete! ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/reactor/cm/link.rb', line 72 def delete! request = XmlRequest.prepare do |xml| xml.where_key_tag!(base_name, "id", @link_id) xml.tag!("#{base_name}-delete") end request.execute! end |
#eql?(other) ⇒ Boolean
68 69 70 |
# File 'lib/reactor/cm/link.rb', line 68 def eql?(other) link_id == other.link_id end |
#hash ⇒ Object
62 63 64 65 66 |
# File 'lib/reactor/cm/link.rb', line 62 def hash # yes, to_s.to_is is neccesary, # because self.link_id is of type REXML::Text for the most of the time link_id.to_s.to_i end |
#is_external? ⇒ Boolean
29 30 31 |
# File 'lib/reactor/cm/link.rb', line 29 def is_external? @is_external == true end |
#is_internal? ⇒ Boolean
33 34 35 |
# File 'lib/reactor/cm/link.rb', line 33 def is_internal? !is_external? end |
#save! ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/reactor/cm/link.rb', line 49 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 request.execute! end |