class Parser::ComponentChooser
Abstraction to choose the component (custom or default)
Attributes
component[R]
Public Class Methods
new(args)
click to toggle source
# File lib/ngi/parser.rb, line 31 def initialize(args) chosen_type = -> (c) { c['name'] == args[:type] } @component = args[:components_hash].find(&chosen_type) return unless args[:config_hash].key? 'templates' custom = args[:config_hash]['templates'].find(&chosen_type) language = args[:config_hash]['language'].collect { |_, v| v } return if custom.nil? template = custom['templates'] .find { |t| language.include? t['language'] } return if template.nil? template = template['template'] # Rebuild the object to be used by Delegate::Generator custom = { 'type' => custom['type'], 'using' => 'user', 'template' => template, 'name' => custom['name'] } @component = custom end