Sha256: e7866f146b75a5e4199ea0e7076b8bf29177ec71d68cf975a918d2adf008bfee
Contents?: true
Size: 1.52 KB
Versions: 5
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true module AwsCftTools class TemplateSet ## # Array methods that need to be overridden to work well with template sets. # module ArrayMethods ## # create a new template set holding templates in either set without duplicates # # Note that this is identical to `|`. # # @param other [AwsCftTools::TemplateSet] # @return [AwsCftTools::TemplateSet] # def +(other) self.class.new(super(other).uniq(&:name)).tap do |union| union.known_exports = @known_exports end end ## # create a new template set holding templates in either set without duplicates # # @param other [AwsCftTools::TemplateSet] # @return [AwsCftTools::TemplateSet] # def |(other) self + other end ## # create a new template set holding templates in the first set not in the second # # @param other [AwsCftTools::TemplateSet] # @return [AwsCftTools::TemplateSet] # def -(other) forbidden_names = other.map(&:name) clone.replace_list( reject { |template| forbidden_names.include?(template.name) } ) end ## # @return [AwsCftTools::TemplateSet] # @yield [AwsCftTools::Template] # def select return unless block_given? clone.replace_list(super) end protected def replace_list(new_list) self[0..size - 1] = new_list self end end end end
Version data entries
5 entries across 5 versions & 1 rubygems