Sha256: 5d72379e052de364d96c4f53c2fd30d9e32a8c0ebe1a32122d046170f9c2f0ce
Contents?: true
Size: 674 Bytes
Versions: 8
Compression:
Stored size: 674 Bytes
Contents
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com # All files in this distribution are subject to the terms of the Ruby license. # Extensions for Struct class Struct # Action = Struct.new('Action', :template, :method, :params) # # a = Action.fill(:template => nil, :method => :meth, :params => [1]) # # => #<struct Struct::Action template=nil, method=:meth, params=[1]> def self.fill(hash = {}) instance = new to_s = members.first.respond_to?(:to_str) hash.each do |key, value| key = to_s ? key.to_s : key.to_sym next unless members.include?(key) instance.send("#{key}=", value) end instance end end
Version data entries
8 entries across 8 versions & 3 rubygems