Sha256: bef4bf1ecddaadb7321101d7670ef253b2420336b0909fb40881ee6c465af56d

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

require 'facets/string/bracket'

module ActiveRecordIgnoredAttributes::Inspect

  # TODO: brackets = self.class.default_brackets_for_inspect (configurable via class_inheritable_accessor)

  def inspect_with(attr_names, brackets = ['#<', '>'])
    attr_names ||= id
    body = attr_names.map {|name|
      "#{name}: #{send(name).inspect}"
    }.join(', ')

    "#{self.class} #{body}".
      bracket(*brackets)
  end

  def inspect_without_ignored_attributes
    inspect_with(attributes.keys - self.class.ignored_attributes.map(&:to_s))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_record_ignored_attributes-0.0.1 lib/active_record_ignored_attributes/inspect.rb