module Inspector

Public Instance Methods

attribute_for_inspect(attr_name) click to toggle source
# 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
inspect() click to toggle source
Calls superclass method
# 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