Class: Occi::Core::Mixin

Inherits:
Category show all
Includes:
Helpers::Locatable
Defined in:
lib/occi/core/mixin.rb

Overview

Defines the extension mechanism of the OCCI Core Model. The `Mixin` instance can be used to add `actions`, `attributes`, and custom features to existing `Entity` instances based on a specific `Kind` instance. A `Mixin` instance may depend on other `Mixin` instances (see `#depends`) and may be applied only to `Entity` instances based on specified `Kind` instances (see `#applies`). Some `Mixin` instances have special meaning defined in OCCI Standard documents.

Author:

Constant Summary

Constants included from Helpers::IdentifierValidator

Helpers::IdentifierValidator::PROHIBITED_SCHEMA_CHARS, Helpers::IdentifierValidator::REGEXP_TERM

Constants included from Helpers::Renderable

Helpers::Renderable::RENDERER_FACTORY_CLASS

Instance Attribute Summary collapse

Attributes inherited from Category

#attributes, #identifier, #schema, #term, #title

Instance Method Summary collapse

Methods inherited from Category

#==, #eql?, #hash, #initialize, #to_s, #valid!, #valid?

Methods included from Helpers::YamlSummoner

#from_yaml, #needs_dereferencing?

Methods included from Helpers::IdentifierValidator

#prohibited_chars!, #valid_identifier!, #valid_identifier?, #valid_schema!, #valid_schema?, #valid_term!, #valid_term?, #valid_uri!

Methods included from Helpers::AttributesAccessor

#[], #[]=

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::Category

Instance Attribute Details

#actionsSet

list of `Action` instances attached to this mixin instance

Returns:

  • (Set)

    the current value of actions


18
19
20
# File 'lib/occi/core/mixin.rb', line 18

def actions
  @actions
end

#appliesSet

list of `Kind` instances to which this mixin can be applied

Returns:

  • (Set)

    the current value of applies


18
19
20
# File 'lib/occi/core/mixin.rb', line 18

def applies
  @applies
end

#dependsSet

list of `Mixin` instances on which this mixin depends

Returns:

  • (Set)

    the current value of depends


18
19
20
# File 'lib/occi/core/mixin.rb', line 18

def depends
  @depends
end

#locationURI

protocol agnostic location of this mixin instance

Returns:

  • (URI)

    the current value of location


18
19
20
# File 'lib/occi/core/mixin.rb', line 18

def location
  @location
end

Instance Method Details

#applies?(kind) ⇒ TrueClass, FalseClass

Checks whether the given kind is in the applies set of this instance (i.e., this mixin can be applied to an `Entity` instance of the given kind). Checking for applicable kinds is strictly flat (no transitivity is applied). One `Mixin` instance may be applied to multiple kinds (`Entity` instances of the given kind).

Parameters:

  • kind (Kind)

    candidate instance

Returns:


45
46
47
48
# File 'lib/occi/core/mixin.rb', line 45

def applies?(kind)
  return false unless applies && kind
  applies.include? kind
end

#depends?(mixin) ⇒ TrueClass, FalseClass

Checks whether the given mixin is in the dependency chains of this instance. Checking for dependencies is strictly flat (no transitivity is applied). One `Mixin` instance may depend on multiple other instances.

Parameters:

  • mixin (Mixin)

    candidate instance

Returns:


31
32
33
34
# File 'lib/occi/core/mixin.rb', line 31

def depends?(mixin)
  return false unless depends && mixin
  depends.include? mixin
end