Sha256: 31e3726ff5483b1465f9e50a1b720d8a600dcf1343b2aa1cfd5aeddcd96fc292
Contents?: true
Size: 365 Bytes
Versions: 2
Compression:
Stored size: 365 Bytes
Contents
module SequelMapper class StructFactory def initialize(struct_class) @constructor = struct_class.method(:new) @members = struct_class.members end attr_reader :constructor, :members private :constructor, :members def call(data) constructor.call( *members.map { |m| data.fetch(m, nil) } ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sequel_mapper-0.0.3 | lib/sequel_mapper/struct_factory.rb |
sequel_mapper-0.0.1 | lib/sequel_mapper/struct_factory.rb |