Class: Occi::Core::Links

Inherits:
Entities show all
Defined in:
lib/occi/core/links.rb

Instance Attribute Summary

Attributes inherited from Entities

#model

Instance Method Summary collapse

Methods inherited from Entities

#as_json, #check, #join

Methods included from Helpers::Inspect

#inspect

Constructor Details

#initialize(links = []) ⇒ Links

Returns a new instance of Links


5
6
7
8
# File 'lib/occi/core/links.rb', line 5

def initialize(links=[])
  links.collect! {|link| convert link} if links
  super links
end

Instance Method Details

#<<(link) ⇒ Object


10
11
12
# File 'lib/occi/core/links.rb', line 10

def <<(link)
  super convert link
end

#convert(link) ⇒ Object (private)


23
24
25
26
27
28
29
30
# File 'lib/occi/core/links.rb', line 23

def convert(link)
  if link.kind_of? String
    target      = link
    link        = Occi::Core::Link.new
    link.target = target
  end
  link
end

#create(*args) ⇒ Object


14
15
16
17
18
19
# File 'lib/occi/core/links.rb', line 14

def create(*args)
  link       = Occi::Core::Link.new(*args)
  link.model = @model
  self << link
  link
end