Class: Humidifier::Loader::StructureContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/humidifier/loader.rb

Overview

Handles searching the PropertyTypes specifications for a specific resource type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(structs) ⇒ StructureContainer

Returns a new instance of StructureContainer.



25
26
27
# File 'lib/humidifier/loader.rb', line 25

def initialize(structs)
  @structs = structs
end

Instance Attribute Details

#structsObject (readonly)

Returns the value of attribute structs.



23
24
25
# File 'lib/humidifier/loader.rb', line 23

def structs
  @structs
end

Instance Method Details

#search(key) ⇒ Object

find the substructures necessary for the given resource key



30
31
32
33
34
# File 'lib/humidifier/loader.rb', line 30

def search(key)
  results = structs.keys.grep(/#{key}/)
  shortened_names = results.map { |result| result.gsub("#{key}.", '') }
  shortened_names.zip(structs.values_at(*results)).to_h.merge(global)
end