Sha256: fdaf07d9befb9b7a14ad05aa96fa6a095d31313533fb86c0ec8610e04783fa96
Contents?: true
Size: 698 Bytes
Versions: 8
Compression:
Stored size: 698 Bytes
Contents
module Yaoc module Helper module StructHashConstructor def self.included(klass) klass.send :prepend, Initializer end module Initializer def initialize(params={}) super() params.each do |attr, value| self.public_send("#{attr}=", value) end if params end end end module_function def StructH(*args, &block) Struct.new(*args, &block).tap do|new_class| new_class.send(:include, Yaoc::Helper::StructHashConstructor) end end def StructHE(*args, &block) StructH(*args, &block).tap do|new_class| include Equalizer.new(*args) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems