Module: Wayfarer::Stringify::InstanceMethods

Defined in:
lib/wayfarer/stringify.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



38
39
40
41
42
43
44
# File 'lib/wayfarer/stringify.rb', line 38

def attributes
  self.class
      .stringified_attributes
      .map { |attr| [attr, public_send(attr)] }
      .to_h
      .map { |k, v| [k, "=", v.inspect].join }
end

#class_nameObject



34
35
36
# File 'lib/wayfarer/stringify.rb', line 34

def class_name
  self.class.name
end

#to_sObject Also known as: inspect



24
25
26
27
28
29
30
# File 'lib/wayfarer/stringify.rb', line 24

def to_s
  if self.class.stringified_attributes.any?
    "#<#{class_name} #{attributes.join(', ')}>"
  else
    "#<#{class_name}>"
  end
end