Top Level Namespace
Defined Under Namespace
Modules: PangeaComponent
Instance Method Summary collapse
Instance Method Details
#component(**kwargs) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pangea-component.rb', line 15 def component(**kwargs) kwargs = symbolize(kwargs) unless kwargs.nil? resource_name = kwargs.fetch(:resource, nil) virtual_name = kwargs.fetch(:name, nil) properties = kwargs.fetch(:properties, {}) resource(resource_name, virtual_name) do properties.each_key do |method| args = kwargs.dig(:properties, method) send(method, args) end end outputs = {} outputs[:inputs] = kwargs # future handle for extracted properties # from derived components nil if kwargs[:extracted_properties] outputs end |
#deep_open_struct(hash) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/pangea-component.rb', line 7 def deep_open_struct(hash) Struct.new( hash.map do |key, value| [key, value.is_a?(Hash) ? deep_open_struct(value) : value] end ).tap.call(&:freeze) end |
#symbolize(hash) ⇒ Object
3 4 5 |
# File 'lib/pangea-component.rb', line 3 def symbolize(hash) JSON[JSON[hash], symbolize_names: true] end |