Module: ActiveRecordIgnoredAttributes::Inspect

Defined in:
lib/active_record_ignored_attributes/inspect.rb

Instance Method Summary collapse

Instance Method Details

#attributes_for_inspectObject



17
18
19
20
# File 'lib/active_record_ignored_attributes/inspect.rb', line 17

def attributes_for_inspect
  [:id].map(&:to_s) + 
  (attributes.keys - self.class.ignored_attributes.map(&:to_s))
end

#inspect_with(attr_names, brackets = ['#<', '>']) ⇒ Object

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



7
8
9
10
11
12
13
14
15
# File 'lib/active_record_ignored_attributes/inspect.rb', line 7

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

#inspect_without_ignored_attributesObject



22
23
24
# File 'lib/active_record_ignored_attributes/inspect.rb', line 22

def inspect_without_ignored_attributes
  inspect_with(attributes_for_inspect)
end