# File lib/hammer_cli_foreman/commands.rb, line 399 def self.associated_resource(name=nil) @associated_api_resource = HammerCLIForeman.foreman_resource!(name) unless name.nil? return @associated_api_resource if @associated_api_resource return superclass.associated_resource if superclass.respond_to? :associated_resource end
# File lib/hammer_cli_foreman/commands.rb, line 375 def self.create_option_builder configurator = BuilderConfigurator.new(searchables, dependency_resolver) builder = ForemanOptionBuilder.new(searchables) builder.builders = [ SearchablesOptionBuilder.new(resource, searchables), DependentSearchablesOptionBuilder.new(associated_resource, searchables) ] resources = [] resources += dependency_resolver.resource_dependencies(resource, :only_required => true, :recursive => true) resources += dependency_resolver.resource_dependencies(associated_resource, :only_required => true, :recursive => true) resources.each do |r| builder.builders << DependentSearchablesOptionBuilder.new(r, searchables) end builder.builders << IdOptionBuilder.new(resource) builder end
# File lib/hammer_cli_foreman/commands.rb, line 395 def associated_resource self.class.associated_resource end
# File lib/hammer_cli_foreman/commands.rb, line 433 def association_name(plural = false) plural ? associated_resource.name.to_s : associated_resource.singular_name.to_s end
# File lib/hammer_cli_foreman/commands.rb, line 405 def get_associated_identifier get_resource_id(associated_resource, :scoped => true) end
# File lib/hammer_cli_foreman/commands.rb, line 413 def get_current_ids item = HammerCLIForeman.record_to_common_format(resource.call(:show, {:id => get_identifier})) if item.has_key?(association_name(true)) item[association_name(true)].map { |assoc| assoc['id'] } else item[association_name+'_ids'] || [] end end
# File lib/hammer_cli_foreman/commands.rb, line 409 def get_new_ids [] end
# File lib/hammer_cli_foreman/commands.rb, line 422 def request_params params = super if params.key?(resource.singular_name) params[resource.singular_name] = {"#{association_name}_ids" => get_new_ids } else params["#{association_name}_ids"] = get_new_ids end params['id'] = get_identifier params end
Generated with the Darkfish Rdoc Generator 2.