Sha256: 2ea9d4fe6690370a3e618797a08431b6b420f783f0d63f3620203841a3d5672d

Contents?: true

Size: 983 Bytes

Versions: 3

Compression:

Stored size: 983 Bytes

Contents

module CukeModeler

  # NOT A PART OF THE PUBLIC API
  # A mix-in module containing methods used by models that represent an element that can be tagged.

  module Taggable

    # The models for tags which are directly assigned to the element
    attr_accessor :tags


    # Returns the models for tags which are indirectly assigned to the element (i.e. they
    # have been inherited from a parent element).
    def applied_tags
      parent_model.respond_to?(:all_tags) ? parent_model.all_tags : []
    end

    # Returns models for all of the tags which are applicable to the element.
    def all_tags
      applied_tags + @tags
    end


    private


    def tag_output_string
      tags.map(&:name).join(' ')
    end

    def populate_tags(model, parsed_model_data)
      return unless parsed_model_data['tags']

      parsed_model_data['tags'].each do |tag|
        model.tags << build_child_model(Tag, tag)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cuke_modeler-3.6.0 lib/cuke_modeler/taggable.rb
cuke_modeler-3.5.0 lib/cuke_modeler/taggable.rb
cuke_modeler-3.4.0 lib/cuke_modeler/taggable.rb