github.com/vchain-us/vcn@v0.9.11-0.20210921212052-a2484d23c0b3/pkg/extractor/options.go (about)

     1  /*
     2   * Copyright (c) 2018-2020 vChain, Inc. All Rights Reserved.
     3   * This software is released under GPL3.
     4   * The full license information can be found under:
     5   * https://www.gnu.org/licenses/gpl-3.0.en.html
     6   *
     7   */
     8  
     9  package extractor
    10  
    11  // Option is a functional option for extractors.
    12  type Option func(interface{}) error
    13  
    14  // Options is a slice of Option.
    15  type Options []Option
    16  
    17  // Apply interates over Options and calls each functional option with a given opts.
    18  func (o Options) Apply(opts interface{}) error {
    19  	for _, f := range o {
    20  		if err := f(opts); err != nil {
    21  			return err
    22  		}
    23  	}
    24  
    25  	return nil
    26  }