Class: DTK::DSL::FileGenerator::ContentInput::Hash

Inherits:
InputOutputCommon::Canonical::Hash show all
Includes:
Mixin
Defined in:
lib/dsl/file_generator/content_input/hash.rb

Instance Attribute Summary

Attributes included from Mixin

#tags

Instance Method Summary collapse

Methods included from Mixin

#add_tags!, #add_tags?, #add_tags_to_obj?, #id_handle, #initialize_tags_and_id_handle!, #matches_tag_type?, #obj_has_tag_type?, #set_id_handle

Methods inherited from InputOutputCommon::Canonical::Hash

#remove_all_except!, #req, #set?

Constructor Details

#initialize(*args) ⇒ Hash

Returns a new instance of Hash.



24
25
26
27
# File 'lib/dsl/file_generator/content_input/hash.rb', line 24

def initialize(*args)
  super
  initialize_tags_and_id_handle!
end

Instance Method Details

#set(output_key, val, opts = {}) ⇒ Object

opts can have keys

:tags
:tag


32
33
34
35
36
37
# File 'lib/dsl/file_generator/content_input/hash.rb', line 32

def set(output_key, val, opts = {})
  ret = super(output_key, val)
  tags = opts[:tag] || opts[:tags]
  add_tags_to_obj?(ret, tags) unless tags.nil?
  ret
end

#val(output_key, opts = {}) ⇒ Object

opts can have keys

:tag - tag to filter on


41
42
43
44
45
46
47
# File 'lib/dsl/file_generator/content_input/hash.rb', line 41

def val(output_key, opts = {})
  ret = super(output_key)
  if tag = opts[:tag]
    ret = nil unless obj_has_tag?(ret, tag)
  end
  ret
end