module CukeModeler::Taggable

@api private

A mix-in module containing methods used by models that represent an element that can be tagged. Internal helper class.

Attributes

tags[RW]

@api

The models for tags which are directly assigned to the element

Public Instance Methods

all_tags() click to toggle source

@api

Returns models for all of the tags which are applicable to the element.

@example

model.all_tags

@return [Array<Tag>] All tag models

# File lib/cuke_modeler/taggable.rb, line 36
def all_tags
  applied_tags + @tags
end
applied_tags() click to toggle source

@api

Returns the models for tags which are indirectly assigned to the element (i.e. they have been inherited from a parent element).

@example

model.applied_tags

@return [Array<Tag>] Applied tag models

# File lib/cuke_modeler/taggable.rb, line 24
def applied_tags
  parent_model.respond_to?(:all_tags) ? parent_model.all_tags : []
end

Private Instance Methods

populate_tags(parsed_model_data) click to toggle source
# File lib/cuke_modeler/taggable.rb, line 48
def populate_tags(parsed_model_data)
  return unless parsed_model_data['tags']

  parsed_model_data['tags'].each do |tag|
    @tags << build_child_model(Tag, tag)
  end
end
tag_output_string() click to toggle source
# File lib/cuke_modeler/taggable.rb, line 44
def tag_output_string
  tags.map(&:name).join(' ')
end