Theocacao
Leopard
Design Element
Comment on "Attribute Values in Rails"
by Jo — Nov 01
You may first put "def scrub_attributes...end" within "class Hash; ...; end" (together with a modified "self.each do |key, value|..."). Then you can use "puts anykindofhash.scrub_attributes".

A way to make a hash an editable variable within a class is to use "def initialize":

class HashOfNames;
def hashofnames; @hashofnames; end;
def initialize; @hashofnames = {"firstname" => " lastname"}; end;
end;

edit = HashOfNames.new;
p a = edit.hashofnames;
p a.scrub_attributes;
p a

(You may also use @@hashofnames in class HashOfNames)
Back to "Attribute Values in Rails"
Design Element

Copyright © Scott Stevenson 2004-2015