Module: Inspector
- Included in:
- Elibri::ONIX::Release_3_0::Contributor, Elibri::ONIX::Release_3_0::Header, Elibri::ONIX::Release_3_0::Language, Elibri::ONIX::Release_3_0::ONIXMessage, Elibri::ONIX::Release_3_0::Product, Elibri::ONIX::Release_3_0::Publisher, Elibri::ONIX::Release_3_0::Sender, Elibri::ONIX::Release_3_0::SupportingResource, Elibri::ONIX::Release_3_0::TextContent
- Defined in:
- lib/elibri_onix/inspector.rb
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 |
#inspect ⇒ Object
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 |