Sha256: 15f35e03fd1af6467c368fd70c9e0c05220277bd9130ca2c3a4ed878cfba5789
Contents?: true
Size: 706 Bytes
Versions: 1
Compression:
Stored size: 706 Bytes
Contents
# frozen_string_literal: true module AddressConcern module InspectBase def inspect_base(*_items, class: true, id: true) items = _items.map { |item| if item.is_a?(Hash) item.map { |k, v| "#{k}: #{v}" }.join(', ') elsif item.respond_to?(:to_proc) && item.to_proc.arity <= 0 item.to_proc.(self) else item.to_s end } _class = binding.local_variable_get(:class) _id = binding.local_variable_get(:id) '<' + [ (_class == true ? self.class : _class), ("#{self.id || 'new'}:" if _id), ].join(' ') + ' ' + [ *items, ].filter_map(&:presence).map(&:to_s).join(', ') + '>' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
address_concern-2.1.0 | app/models/concerns/inspect_base.rb |