Created
June 7, 2018 08:36
-
-
Save slavakisel/6f04743d2318904b1b17e03d806758ae to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Inspector | |
| extend ActiveSupport::Concern | |
| included do | |
| def inspect | |
| inspection = @attributes ? inspected_attributes : "not initialized" | |
| "#<#{self.class} #{inspection}>" | |
| end | |
| def inspected_attributes | |
| self.class.column_names | |
| .select { |c| c.exclude?(*exclude_from_inspect) } | |
| .collect { |name| "#{name}: #{attribute_for_inspect(name)}" if has_attribute?(name) } | |
| .compact | |
| .join(", ") | |
| end | |
| def exclude_from_inspect | |
| [] | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment