mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-06 06:28:33 +00:00
Fixed matchup object to hash and hash to object
This commit is contained in:
@@ -5,5 +5,20 @@ class Matchup
|
||||
@weight = Weight.find(self.weight_id)
|
||||
return @weight.max
|
||||
end
|
||||
|
||||
def to_hash
|
||||
hash = {}
|
||||
instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
|
||||
hash
|
||||
end
|
||||
|
||||
def convert_to_obj(h)
|
||||
h.each do |k,v|
|
||||
self.class.send(:attr_accessor, k)
|
||||
instance_variable_set("@#{k}", v)
|
||||
convert_to_obj(v) if v.is_a? Hash
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user