Skip to content

Commit

Permalink
Add introspection methods
Browse files Browse the repository at this point in the history
  • Loading branch information
flash-gordon committed May 11, 2024
1 parent c1ab0f5 commit 1ff1ce6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/rom/factory/attribute_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def reject(&block)
self.class.new(elements.reject(&block))
end

# @api private
def inspect
"#<#{self.class} #{elements.inspect}>"
end
alias_method :to_s, :inspect

private

# @api private
Expand Down
6 changes: 6 additions & 0 deletions lib/rom/factory/attributes/callable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def value?
def dependency_names
block.parameters.map(&:last)
end

# @api private
def inspect
"#<#{self.class.name} #{name} at #{block.source_location.join(":")}>"
end
alias_method :to_s, :inspect
end
end
end
5 changes: 5 additions & 0 deletions lib/rom/factory/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ def association(name, *traits, **options)
_attributes << attributes::Association.new(assoc, builder, *traits, **options)
end

# @api private
def inspect
"#<#{self.class} name=#{_name}>"
end
alias_method :to_s, :inspect

private

Expand Down

0 comments on commit 1ff1ce6

Please sign in to comment.