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.



21
22
23
# File 'lib/humidifier/loader.rb', line 21

def initialize(structs)
  @structs = structs
end

Instance Attribute Details

#structsObject (readonly)

Returns the value of attribute structs.



19
20
21
# File 'lib/humidifier/loader.rb', line 19

def structs
  @structs
end

Instance Method Details

#search(key) ⇒ Object

find the substructures necessary for the given resource key



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

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