Module: Inspector

Instance Method Summary collapse

Instance Method Details

#attribute_for_inspect(attr_name) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/elibri_onix/inspector.rb', line 3

def attribute_for_inspect(attr_name)
  value = self.send(attr_name)

  if value.is_a?(String) && value.length > 50
    "#{value[0..50]}...".inspect
  elsif value.is_a?(Date) || value.is_a?(Time)
    %("#{value.to_s(:db)}")
  else
    value.inspect
  end
end

#inspectObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/elibri_onix/inspector.rb', line 15

def inspect
  if self.respond_to?(:inspect_include_fields)
    attributes_as_nice_string = self.inspect_include_fields.collect { |name|
      "#{name}: #{attribute_for_inspect(name)}"
    }.compact.join(", ")
    "#<#{self.class} #{attributes_as_nice_string}>"
  else
    super
  end
end