Sha256: fecbfbdd7571d733b867d9d4d7c82967b7fd792967408bd5761c3a56b56d21c7

Contents?: true

Size: 784 Bytes

Versions: 3

Compression:

Stored size: 784 Bytes

Contents

module Inch
  module API
    # Gets all objects matching the given +object_names+
    class Get < Filter
      attr_reader :object

      def initialize(codebase, object_names)
        super(codebase, {})
        @objects = find_objects_with_names(object_names)
        @object = objects.first
      end

      private

      # Returns all objects matching the given +object_names+
      #
      # @param object_names [Array<String>]
      # @return [Array<CodeObject::Proxy::Base>]
      def find_objects_with_names(object_names)
        object_names.map do |object_name|
          if (object = codebase.objects.find(object_name))
            object
          else
            codebase.objects.starting_with(object_name)
          end
        end.flatten
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
inch-0.4.10 lib/inch/api/get.rb
inch-0.4.9 lib/inch/api/get.rb
inch-0.4.8 lib/inch/api/get.rb