lib/custom_facts/core/aggregate.rb
# Define a new chunk for the given aggregate
#
# @api public
#
# @example Defining a chunk with no dependencies
#   aggregate.chunk(:mountpoints) do
#     # generate mountpoint information
#   end
#
# @example Defining an chunk to add mount options
#   aggregate.chunk(:mount_options, :require => [:mountpoints]) do |mountpoints|
#     # `mountpoints` is the result of the previous chunk
#     # generate mount option information based on the mountpoints
#   end
#
# @param name [Symbol] A name unique to this aggregate describing the chunk
# @param opts [Hash]
# @options opts [Array<Symbol>, Symbol] :require One or more chunks
#   to evaluate and pass to this block.
# @yield [*Object] Zero or more chunk results
#
# @return [void]
Define a new chunk for the given aggregate
Define a new chunk for the given aggregate
def chunk(name, opts = {}, &block)
        raise ArgumentError, "#{self.class.name}#chunk requires a block" unless block_given?
        deps = Array(opts.delete(:require))
        unless opts.empty?
          raise ArgumentError, "Unexpected options passed to #{self.class.name}#chunk: #{opts.keys.inspect}"
        end
        @deps[name] = deps
        @chunks[name] = block
      end
def chunk ( name , opts = { } , & block ) raise ArgumentError , "#{self.class.name}#chunk requires a block" unless block_given? deps = Array ( opts . delete ( :require ) ) unless opts . empty? raise ArgumentError , "Unexpected options passed to #{self.class.name}#chunk: #{opts.keys.inspect}" end @deps [ name ] = deps @chunks [ name ] = block end
Define a new chunk for the given aggregate
Define a new chunk for the given aggregate
None
void
name
A name unique to this aggregate describing the chunk
A name unique to this aggregate describing the chunk
opts
<not_specific>
block
<not_specific>
<not_specific>
None
]
<not_specific>
Zero or more chunk results
Zero or more chunk results
api
None
example
Defining a chunk with no dependencies aggregate.chunk(:mountpoints) do # generate mountpoint information end
Defining a chunk with no dependencies aggregate . chunk ( : mountpoints ) do # generate mountpoint information end
example
Defining an chunk to add mount options aggregate.chunk(:mount_options, :require => [:mountpoints]) do |mountpoints| # `mountpoints` is the result of the previous chunk # generate mount option information based on the mountpoints end
Defining an chunk to add mount options aggregate . chunk ( : mount_options : require = > [ : mountpoints ] ) do |mountpoints| # ` mountpoints ` is the result of the previous chunk # generate mount option information based on the mountpoints end
options
opts [Array, Symbol] :require One or more chunks to evaluate and pass to this block.
opts [ Array Symbol ] : require One or more chunks to evaluate and pass to this block .