Path: | doc/option_builder.md |
Last Update: | Tue Mar 10 13:27:41 -0400 2015 |
Option Builders
Commands in the Foreman plugin have by default option builders for:
The latter creates options for identifying resources based on the action‘s parameters and definition of the resource‘s searchable fields (_any field that is unique either globally or in a scope and is accessible in scoped search at the same time_). The searchables definition is kept in [a single mapping object](../lib/hammer_cli_foreman/id_resolver.rb).
__The builder creates:__
However, this default behavior is not always applicable. Therefore the builder enables customizing the set of expanded resources.
See examples in the code below.
```ruby build_options do |o|
o.expand(:all) # will do all expansions (default) o.expand(:none) # will not expand anything o.expand(:all).including(:locations) # will create additional identifier # options for locations o.expand.including(:locations) # equivalent to the above o.expand(:all).except(:organizations) # create identifier options for all resources # except from organizations o.expand.only(:architectures, :domains) # expand searchables for specific # set of resources # it is also possible to combine the methods o.expand(:all).including(:locations).except(:organizations)
end ```