lib/outliers/collection.rb in outliers-0.2.0 vs lib/outliers/collection.rb in outliers-0.3.0

- old
+ new

@@ -35,19 +35,19 @@ @provider = provider @logger = Outliers.logger end def each &block - all.each do |resource| + list.each do |resource| block.call resource end end def exclude_by_key(exclusions) @logger.info "Excluding the following resources: '#{exclusions.join(',')}'." - save = all.reject {|u| exclusions.include? u.public_send key} - @all = save + save = list.reject {|u| exclusions.include? u.public_send key} + @list = save end def filter(args) name = args.keys.first value = args.fetch name @@ -60,22 +60,22 @@ filtered_list = self.public_send "filter_#{name}", value logger.warn "No resources match filter." unless filtered_list.any? - @all = filtered_list + @list = filtered_list end def verify(name, arguments={}) name << "?" unless name =~ /^.*\?$/ - unless all.any? + unless list.any? return { failing_resources: [], passing_resources: [] } end logger.info "Verifying '#{name}'." - logger.debug "Target resources '#{all_by_key.join(', ')}'." + logger.debug "Target resources '#{list_by_key.join(', ')}'." unless verification_exists? name raise Exceptions::UnknownVerification.new "Unkown verification '#{name}'." end @@ -84,12 +84,12 @@ else send_resources_verification name, arguments end end - def all - @all ||= load_all + def list + @list ||= load_all end def key resource_class.key end @@ -105,12 +105,12 @@ m += Outliers::Verifications::Shared.instance_methods m -= [:source, :id, :method_missing] m.include? name.to_sym end - def all_by_key - all.map {|r| r.public_send key} + def list_by_key + list.map {|r| r.public_send key} end def connect @provider.connect end @@ -124,32 +124,32 @@ end def set_target_resources(verification) logger.info "Verifying target '#{targets.join(', ')}'." - @all = all.select {|r| targets.include? r.id } + @list = list.select {|r| targets.include? r.id } - unless all.any? + unless list.any? raise Outliers::Exceptions::TargetNotFound.new "No resources found matching one or more of '#{targets}'." end - @all + @list end def send_resources_verification(verification, arguments) set_target_resources verification if targets.any? failing_resources = reject do |resource| result = send_verification resource, verification, arguments logger.debug "Verification of resource '#{resource.id}' #{result ? 'passed' : 'failed'}." result end - { failing_resources: failing_resources, passing_resources: all - failing_resources } + { failing_resources: failing_resources, passing_resources: list - failing_resources } end def send_collection_verification(verification, arguments) failing_resources = send_verification(self, verification, arguments) - { failing_resources: failing_resources, passing_resources: all - failing_resources } + { failing_resources: failing_resources, passing_resources: list - failing_resources } end def send_verification(object, verification, arguments) if object.method(verification).arity.zero? if arguments.any?