Module: DTK::DSL::FileGenerator::ContentInput::Mixin

Included in:
Array, Hash, String
Defined in:
lib/dsl/file_generator/content_input/mixin.rb

Overview

Mixin for tags and id_handle object attributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tagsObject (readonly)

Returns the value of attribute tags.



22
23
24
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 22

def tags
  @tags
end

Instance Method Details

#add_tags!(new_tags) ⇒ Object



36
37
38
39
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 36

def add_tags!(new_tags)
  Tag.add_tags!(@tags, new_tags)
  self
end

#add_tags?(new_tags) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 41

def add_tags?(new_tags)
  add_tags!(new_tags) unless new_tags.nil? or new_tags.empty?
end

#add_tags_to_obj?(obj, new_tags) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 49

def add_tags_to_obj?(obj, new_tags) 
  obj.add_tags!(new_tags) if obj.respond_to?(:add_tags!)
  obj
end

#id_handleObject



32
33
34
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 32

def id_handle
  @id_handle || raise(Error,"@id_handle is not set")
end

#initialize_tags_and_id_handle!Object



23
24
25
26
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 23

def initialize_tags_and_id_handle!
  @tags      = []
  @id_handle = nil
end

#matches_tag_type?(tag_type) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 45

def matches_tag_type?(tag_type)
  !! @tags.find { |tag| Tag.matches_tag_type?(tag_type, tag) }
end

#obj_has_tag_type?(obj, tag_type) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
58
59
60
61
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 54

def obj_has_tag_type?(obj, tag_type)  
  if obj.respond_to?(:matches_tag_type?)
    obj.matches_tag_type?(tag_type)
  else
    # vacuously succeeds
    true
  end
end

#set_id_handle(model_object) ⇒ Object



28
29
30
# File 'lib/dsl/file_generator/content_input/mixin.rb', line 28

def set_id_handle(model_object)
  @id_handle = model_object.id_handle
end