Sha256: f35f72a33f4b963d8709e9ec4018c59cddf7347b75380de66bf3f9b01e4ac360

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

module CukeModeler

  # A mix-in module containing methods used by elements that can be tagged.

  module Taggable

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

    # The tag elements belonging to the element
    attr_accessor :tag_elements


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

    # Returns the tags elements which are indirectly assigned to the element
    # (i.e. they have been inherited from a parent element).
    def applied_tag_elements
      @parent_element.respond_to?(:all_tag_elements) ? @parent_element.all_tag_elements : []
    end

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

    # Returns all of the tag elements which are applicable to the element.
    def all_tag_elements
      applied_tag_elements + @tag_elements
    end


    private


    def populate_element_tags(parsed_element)
      if parsed_element['tags']
        parsed_element['tags'].each do |tag|
          @tags << tag['name']
          @tag_elements << build_child_element(Tag, tag)
        end
      end
    end

    def tag_output_string
      tag_elements.collect { |tag| tag.name }.join(' ')
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cuke_modeler-0.4.1 lib/cuke_modeler/taggable.rb
cuke_modeler-0.4.0 lib/cuke_modeler/taggable.rb
cuke_modeler-0.3.0 lib/cuke_modeler/taggable.rb
cuke_modeler-0.2.0 lib/cuke_modeler/taggable.rb
cuke_modeler-0.1.0 lib/cuke_modeler/taggable.rb
cuke_modeler-0.0.2 lib/cuke_modeler/taggable.rb
cuke_modeler-0.0.1 lib/cuke_modeler/taggable.rb