Sha256: 5de53d947f14bc0dde6e991eddedbdb4a7b4bd2adc262fe46e09c46e80c3b743
Contents?: true
Size: 1019 Bytes
Versions: 25
Compression:
Stored size: 1019 Bytes
Contents
module Exlibris module Primo # # Write passed in arguments to instance attributes # module WriteAttributes def initialize *args # Just call super w/o any args for now. Eventually, we'll want to check the arity and adjust. # self.class.superclass.instance_method(:initialize).arity.eql? self.class.instance_method(:initialize).arity super() write_attributes args.last unless args.last.nil? end def write_attributes attributes attributes.each do |attribute, value| write_attribute attribute, value end end def attributize symbol symbol.id2name.sub(/=$/, "").to_sym end protected :attributize def write_attribute attribute, value attribute_writer = writify attribute send attribute_writer, value if respond_to? attribute_writer end private :write_attribute def writify key "#{key}=".to_sym end private :writify end end end
Version data entries
25 entries across 25 versions & 1 rubygems