Sha256: 81a3e45f807731cd150f51a8500708cc335187c32c87265db67d87e59de1649b
Contents?: true
Size: 775 Bytes
Versions: 3
Compression:
Stored size: 775 Bytes
Contents
require 'anima' require 'rom/struct' module ROM class Repository < Gateway # @api private class StructBuilder attr_reader :registry def self.registry @__registry__ ||= {} end def initialize @registry = self.class.registry end def call(*args) name, columns = args registry[args.hash] ||= build_class(name) { |klass| klass.send(:include, Anima.new(*columns)) } end alias_method :[], :call private def build_class(name, &block) ROM::ClassBuilder.new(name: class_name(name), parent: Struct).call(&block) end def class_name(name) "ROM::Struct[#{Inflector.classify(Inflector.singularize(name))}]" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rom-repository-0.1.0 | lib/rom/repository/struct_builder.rb |
rom-repository-0.0.2 | lib/rom/repository/struct_builder.rb |
rom-repository-0.0.1 | lib/rom/repository/struct_builder.rb |