Skip to content

Commit

Permalink
Fix missing yard docs
Browse files Browse the repository at this point in the history
After adding `yard` to the Rakefile, yard warnings and errors became
easy to spot. Fix up errors and add missing docs.
  • Loading branch information
Paul DobbinSchmaltz committed Nov 15, 2023
1 parent 454ebcb commit 4ee274a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
6 changes: 6 additions & 0 deletions lib/object_identifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,30 @@ def self.call(

# Default Configuration Accessors

# The default formatter class to use ({ObjectIdentifier::StringFormatter}).
def self.default_formatter_class
configuration.formatter_class
end

# The default attributes to include on object inspections.
def self.default_attributes
configuration.default_attributes
end

# Custom Configuration Getters/Setters

# Accessor for the {ObjectIdentifier::Configuration} object.
def self.configuration
@configuration ||= Configuration.new
end

# @yieldparam configuration [ObjectIdentifier::Configuration]
def self.configure
yield(configuration)
end

# Reset the current configuration settings memoized by
# {ObjectIdentifier.configuration}.
def self.reset_configuration
@configuration = Configuration.new
end
Expand Down
2 changes: 1 addition & 1 deletion lib/object_identifier/array_wrap.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# ObjectIdentifier::ArrayWrap mirrors the implementation of Rails'
# {Array.wrap} method. This allows us to get around objects that respond to
# Array.wrap method. This allows us to get around objects that respond to
# `to_a` (such as Struct) and, instead, either utilize `to_ary` or just
# actually wrap the object in an Array ourselves.
class ObjectIdentifier::ArrayWrap
Expand Down
5 changes: 3 additions & 2 deletions lib/object_identifier/formatters/base_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class ObjectIdentifier::BaseFormatter
attr_reader :objects,
:parameters

def self.call(*args, **kwargs)
new(*args, **kwargs).call
# A shortcut for calling `new(...).call`.
def self.call(...)
new(...).call
end

# @param objects [Object, [Object, ...]] the object(s) to be interrogated for
Expand Down
5 changes: 5 additions & 0 deletions lib/object_identifier/formatters/string_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# ObjectIdentifier::StringFormatter builds a String to identify the
# given object(s).
class ObjectIdentifier::StringFormatter < ObjectIdentifier::BaseFormatter
# The String to output when the {#objects} is empty.
NO_OBJECTS_INDICATOR = "[no objects]"

# Output the self-identifying string for the given object(s). Will either
Expand Down Expand Up @@ -45,6 +46,10 @@ def initialize(objects, parameters)
@parameters = parameters
end

# Build a comma-separated list of formatted item Strings representing the
# given objects.
#
# @return [String]
def call
parts = objects.first(limit).map { |obj| format_item(obj) }
parts << "... (#{truncated_objects_count} more)" if truncated?
Expand Down
5 changes: 3 additions & 2 deletions lib/object_identifier/parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# formatter options that may be needed for custom formatting during object
# identification.
class ObjectIdentifier::Parameters
# This String to display if `formatter_options[:klass]` isn't present.
KLASS_NOT_GIVEN = "NOT_GIVEN"

attr_reader :attributes
Expand All @@ -23,9 +24,9 @@ def self.build(attributes: [], formatter_options: {})

# @param attributes [Array, *args] a list of method calls to interrogate the
# given object(s) with
# @param formatter_options[:limit] [Integer, nil] (nil) a given limit on the
# @option formatter_options[:limit] [Integer, nil] (nil) a given limit on the
# number of objects to interrogate
# @param formatter_options[:klass] [#to_s] a preferred type name for
# @option formatter_options[:klass] [#to_s] a preferred type name for
# identifying the given object(s) as
def initialize(
attributes: [],
Expand Down
1 change: 1 addition & 0 deletions lib/object_identifier/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

module ObjectIdentifier
# The current ObjectIdentifier gem version.
VERSION = "0.6.0"
end

0 comments on commit 4ee274a

Please sign in to comment.