Module: Wayfarer::Stringify

Extended by:
ActiveSupport::Concern
Included in:
Routing::Matchers::Custom, Routing::Route, Task
Defined in:
lib/wayfarer/stringify.rb

Instance Method Summary collapse

Instance Method Details

#to_sObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/wayfarer/stringify.rb', line 22

def to_s
  class_name = self.class.name

  if self.class.stringified_attributes.any?
    attrs = self.class
                .stringified_attributes
                .map { |attr| [attr, public_send(attr)] }
                .to_h
                .map { |k, v| "#{k}=#{v.inspect}" }
                .join(", ")

    "#<#{class_name} #{attrs}>"
  else
    "#<#{class_name}>"
  end
end