module StructCast::CoreExt
Public Instance Methods
convert_to_hash()
click to toggle source
# File lib/struct_cast.rb, line 8 def convert_to_hash if self.respond_to? :to_hash self.to_hash elsif self.respond_to? :to_h self.to_h else raise ::TypeError, "can't convert #{self.class.name} to Hash" end end
symbolize_keys()
click to toggle source
# File lib/struct_cast.rb, line 20 def symbolize_keys self.transform_keys do |k| raise ::TypeError, "can't convert key type to Symbol: #{k.class.name}" unless k.respond_to? :to_sym k.to_sym end end