Sha256: f260d4badd07c68c53f7ca603105578f9b8ef2a384df35d0e0432b9241103d51
Contents?: true
Size: 474 Bytes
Versions: 62
Compression:
Stored size: 474 Bytes
Contents
# encoding: utf-8 # Kernel module Kernel # set attributes from hash # # === Example # # class Person # attr_accessor :name, :age # end # # person = Person.new # person.hash_to_attributes({name: 'hoge', age: 33}) # # result # # #<PersonForHashToAttributes:0x3957858 @age=33, @not_exists="hoge"> # def hash_to_attributes(hash) hash.each { |key, value|instance_variable_set "@#{key}", value } end end
Version data entries
62 entries across 62 versions & 1 rubygems