module AwsCftTools::TemplateSet::ArrayMethods

Array methods that need to be overridden to work well with template sets.

Public Instance Methods

+(other) click to toggle source

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]

Calls superclass method
# File lib/aws_cft_tools/template_set/array_methods.rb, line 17
def +(other)
  self.class.new(super(other).uniq(&:name)).tap do |union|
    union.known_exports = @known_exports
  end
end
-(other) click to toggle source

create a new template set holding templates in the first set not in the second

@param other [AwsCftTools::TemplateSet] @return [AwsCftTools::TemplateSet]

# File lib/aws_cft_tools/template_set/array_methods.rb, line 39
def -(other)
  forbidden_names = other.map(&:name)
  clone.replace_list(
    reject { |template| forbidden_names.include?(template.name) }
  )
end
select() click to toggle source

@return [AwsCftTools::TemplateSet] @yield [AwsCftTools::Template]

Calls superclass method
# File lib/aws_cft_tools/template_set/array_methods.rb, line 50
def select
  return unless block_given?
  clone.replace_list(super)
end
|(other) click to toggle source

create a new template set holding templates in either set without duplicates

@param other [AwsCftTools::TemplateSet] @return [AwsCftTools::TemplateSet]

# File lib/aws_cft_tools/template_set/array_methods.rb, line 29
def |(other)
  self + other
end

Protected Instance Methods

replace_list(new_list) click to toggle source
# File lib/aws_cft_tools/template_set/array_methods.rb, line 57
def replace_list(new_list)
  self[0..size - 1] = new_list
  self
end