Class: Occi::Core::Link

Inherits:
Entity
  • Object
show all
Defined in:
lib/occi/core/link.rb

Overview

Implements the base class for all OCCI links, this class can be used directly to create link instances.

Author:

Constant Summary collapse

URI_PATH_SEPARATOR =

Separator in URI PATHs

'/'.freeze

Constants inherited from Entity

Entity::ERRORS

Constants included from Helpers::Renderable

Helpers::Renderable::RENDERER_FACTORY_CLASS

Instance Attribute Summary collapse

Attributes inherited from Entity

#actions, #attributes, #id, #kind, #location, #mixins, #title

Instance Method Summary collapse

Methods inherited from Entity

#<<, #add_action, #add_mixin, #added_attributes, #availability_zone, #availability_zones, #base_attributes, #disable_action, #enable_action, #identify!, #initialize, #kind_identifier, #region, #regions, #remove, #remove_action, #remove_mixin, #replace_mixin, #valid?

Methods included from Helpers::MixinSelector

#dependent_term, #dependent_term!, #dependent_terms, #select_mixin, #select_mixin!, #select_mixins

Methods included from Helpers::InstanceAttributeResetter

#attribute_names, #remove_undef_attributes, #reset_added_attributes, #reset_added_attributes!, #reset_attribute, #reset_attributes, #reset_attributes!, #reset_base_attributes, #reset_base_attributes!

Methods included from Helpers::InstanceAttributesAccessor

#[], #[]=, #attribute?

Methods included from Helpers::Locatable

#location

Methods included from Helpers::Renderable

extended, included, #render, #renderer_factory, renderer_factory, renderer_factory_class, #renderer_for

Constructor Details

This class inherits a constructor from Occi::Core::Entity

Instance Attribute Details

#sourceURI

Returns link source.

Returns:

  • (URI)

    link source


12
13
14
# File 'lib/occi/core/link.rb', line 12

def source
  @source
end

#source_kindOcci::Core::Kind, NilClass

source kind or `nil` if unknown

Returns:


12
13
14
# File 'lib/occi/core/link.rb', line 12

def source_kind
  @source_kind
end

#targetURI

Returns link target.

Returns:

  • (URI)

    link target


12
13
14
# File 'lib/occi/core/link.rb', line 12

def target
  @target
end

#target_kindOcci::Core::Kind, NilClass Also known as: rel

target kind or `nil` if ourside the domain

Returns:


12
13
14
# File 'lib/occi/core/link.rb', line 12

def target_kind
  @target_kind
end

Instance Method Details

#source_idObject

:nodoc:


58
59
60
# File 'lib/occi/core/link.rb', line 58

def source_id
  last_uri_segment source
end

#target_idObject

:nodoc:


53
54
55
# File 'lib/occi/core/link.rb', line 53

def target_id
  last_uri_segment target
end

#valid!Object

See `#valid!` on `Occi::Core::Entity`.


43
44
45
46
47
48
49
50
# File 'lib/occi/core/link.rb', line 43

def valid!
  super

  i[source target].each do |attr|
    next if valid_uri? send(attr)
    raise Occi::Core::Errors::InstanceValidationError, "Malformed or incomplete occi.core.#{attr}"
  end
end