Module: KDoc::Taggable
Overview
A container acts a base data object for any data that requires tagging such as unique key, type and namespace.
Instance Attribute Summary collapse
-
#tag_options ⇒ Object
readonly
Returns the value of attribute tag_options.
Instance Method Summary collapse
-
#initialize_tag(opts) ⇒ Object
Tags are provided via an options hash, these tags are remove from the hash as they are read.
-
#key ⇒ Object
Name of the document (required).
-
#namespace ⇒ Object
Namespace(s) what namespace is this document under.
-
#project ⇒ Object
TODO: rename to area (or area root namespace) Project name.
- #tag ⇒ Object
-
#type ⇒ Object
Type of data.
Instance Attribute Details
#tag_options ⇒ Object (readonly)
Returns the value of attribute tag_options.
9 10 11 |
# File 'lib/k_doc/mixins/taggable.rb', line 9 def @tag_options end |
Instance Method Details
#initialize_tag(opts) ⇒ Object
Tags are provided via an options hash, these tags are remove from the hash as they are read
Any container can be uniquely identified via it’s key, type, namespace and project_key tags
20 21 22 23 |
# File 'lib/k_doc/mixins/taggable.rb', line 20 def initialize_tag(opts) @tag_options = opts build_tag end |
#key ⇒ Object
Name of the document (required)
Examples: user, account, country
32 33 34 |
# File 'lib/k_doc/mixins/taggable.rb', line 32 def key @key ||= @tag_options.delete(:key) || SecureRandom.alphanumeric(4) end |
#namespace ⇒ Object
Namespace(s) what namespace is this document under
Example for single path
:controllers, :models
Example for deep path
[:app, :controllers, :admin]
63 64 65 66 67 68 |
# File 'lib/k_doc/mixins/taggable.rb', line 63 def namespace return @namespace if defined? @namespace ns = @tag_options.delete(:namespace) || [] @namespace = ns.is_a?(Array) ? ns : [ns] end |
#project ⇒ Object
TODO: rename to area (or area root namespace) Project name
Examples
:app_name1, :app_name2, :library_name1
52 53 54 |
# File 'lib/k_doc/mixins/taggable.rb', line 52 def project @project ||= @tag_options.delete(:project) || '' end |
#tag ⇒ Object
25 26 27 |
# File 'lib/k_doc/mixins/taggable.rb', line 25 def tag return @tag if defined? @tag end |
#type ⇒ Object
Type of data
Examples by data type
:csv, :yaml, :json, :xml
Examples by shape of the data in a DSL
:entity, :microapp, blueprint
43 44 45 |
# File 'lib/k_doc/mixins/taggable.rb', line 43 def type @type ||= @tag_options.delete(:type) || default_container_type end |