Created
September 20, 2020 08:01
-
-
Save alpaca-tc/c7faaebc5e1cb0ebdbf3284b27216976 to your computer and use it in GitHub Desktop.
こういうのが欲しいけれど、どうやったらAM::Modelに入りうるだろうか...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveModelAttributesInspector | |
# @return [String] | |
def inspect | |
values = attributes.map { |key, value| "#{key}: #{value.inspect}" }.join(', ') | |
%(<#{self.class.name} #{values}>) | |
end | |
# @param pp [PP] | |
# | |
# @return [void] | |
def pretty_print(pp) | |
pp.object_address_group(self) do | |
pp.seplist(attributes.keys, proc { pp.text(',') }) do |attr_name| | |
pp.breakable ' ' | |
pp.group(1) do | |
pp.text attr_name.to_s | |
pp.text ':' | |
pp.breakable | |
pp.pp public_send(attr_name) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example
before
after