Module: KDoc::Taggable
Overview
Provide tagging functionality to the underlying model
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.
11 12 13 |
# File 'lib/k_doc/mixins/taggable.rb', line 11 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
22 23 24 25 |
# File 'lib/k_doc/mixins/taggable.rb', line 22 def initialize_tag(opts) @tag_options = opts build_tag end |
#key ⇒ Object
Name of the document (required)
Examples: user, account, country
34 35 36 |
# File 'lib/k_doc/mixins/taggable.rb', line 34 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]
65 66 67 68 69 70 |
# File 'lib/k_doc/mixins/taggable.rb', line 65 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
54 55 56 |
# File 'lib/k_doc/mixins/taggable.rb', line 54 def project @project ||= @tag_options.delete(:project) || '' end |
#tag ⇒ Object
27 28 29 |
# File 'lib/k_doc/mixins/taggable.rb', line 27 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
45 46 47 |
# File 'lib/k_doc/mixins/taggable.rb', line 45 def type @type ||= @tag_options.delete(:type) || default_container_type end |