Class: Occi::Core::Category Abstract
- Inherits:
-
Object
- Object
- Occi::Core::Category
- Extended by:
- Helpers::IdentifierValidator, Helpers::YamlSummoner
- Includes:
- Helpers::ArgumentValidator, Helpers::AttributesAccessor, Helpers::Renderable, Yell::Loggable
- Defined in:
- lib/occi/core/category.rb
Overview
The base class itself is not renderable and should be used as an abstract starting point.
Implements the base class for all OCCI categories, including ‘Kind`, `Action`, and `Mixin`.
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 ⇒ Hash
category attributes.
-
#identifier ⇒ String
readonly
Returns a full category identifier constructed from ‘term` and `schema`.
-
#schema ⇒ String
category schema, ending with ‘#’.
-
#term ⇒ String
category term.
-
#title ⇒ String
category title.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#eql?(other) ⇒ Boolean
:nodoc:.
-
#hash ⇒ Object
:nodoc:.
-
#initialize(args = {}) ⇒ Category
constructor
Constructs an instance with the given category information.
-
#to_s ⇒ Object
:nodoc:.
-
#valid! ⇒ Object
Performs internal validation of the category.
-
#valid? ⇒ TrueClass, FalseClass
Performs internal validation of the category.
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::YamlSummoner
from_yaml, needs_dereferencing?
Methods included from Helpers::AttributesAccessor
Methods included from Helpers::Renderable
extended, included, #render, #renderer_factory, renderer_factory, renderer_factory_class, #renderer_for
Constructor Details
#initialize(args = {}) ⇒ Category
Constructs an instance with the given category information. Both ‘term` and `schema` are mandatory arguments. `schema` must be terminated with ’#‘.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/occi/core/category.rb', line 38 def initialize(args = {}) pre_initialize(args) default_args! args @term = args.fetch(:term) @schema = args.fetch(:schema) @title = args.fetch(:title) @attributes = args.fetch(:attributes) post_initialize(args) end |
Instance Attribute Details
#attributes ⇒ Hash
category attributes
16 17 18 |
# File 'lib/occi/core/category.rb', line 16 def attributes @attributes end |
#identifier ⇒ String (readonly)
Returns a full category identifier constructed from ‘term` and `schema`.
16 17 18 |
# File 'lib/occi/core/category.rb', line 16 def identifier @identifier end |
#schema ⇒ String
category schema, ending with ‘#’
16 17 18 |
# File 'lib/occi/core/category.rb', line 16 def schema @schema end |
#term ⇒ String
category term
16 17 18 |
# File 'lib/occi/core/category.rb', line 16 def term @term end |
#title ⇒ String
category title
16 17 18 |
# File 'lib/occi/core/category.rb', line 16 def title @title end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
94 95 96 97 |
# File 'lib/occi/core/category.rb', line 94 def ==(other) return false unless other && other.respond_to?(:identifier) identifier == other.identifier end |
#eql?(other) ⇒ Boolean
:nodoc:
100 101 102 |
# File 'lib/occi/core/category.rb', line 100 def eql?(other) self == other end |
#hash ⇒ Object
:nodoc:
105 106 107 |
# File 'lib/occi/core/category.rb', line 105 def hash identifier.hash end |
#to_s ⇒ Object
:nodoc:
89 90 91 |
# File 'lib/occi/core/category.rb', line 89 def to_s identifier end |
#valid! ⇒ Object
Performs internal validation of the category. Raises error depending on the result. Currently, only the category identifier is used in this process.
83 84 85 86 |
# File 'lib/occi/core/category.rb', line 83 def valid! # TODO: validate attribute definitions? self.class.valid_identifier! identifier end |
#valid? ⇒ TrueClass, FalseClass
Performs internal validation of the category. Returns ‘true` or `false` depending on the result. Currently, only the category identifier is used in this process.
70 71 72 73 |
# File 'lib/occi/core/category.rb', line 70 def valid? # TODO: validate attribute definitions? self.class.valid_identifier? identifier end |