Sha256: e366d157edf253d5f4cd7b58d6cc189d664dcaa5baf55f86c39759eb7c519243
Contents?: true
Size: 870 Bytes
Versions: 5
Compression:
Stored size: 870 Bytes
Contents
module ROM # @api private class RelationBuilder attr_reader :schema, :mod # @api private def initialize(schema) @schema = schema @mod = schema.each_with_object(Module.new) do |(name, relation), m| m.send(:define_method, name) { relation.dataset } end end # @api private def call(name) schema_relation = schema[name] klass = Class.new(Relation) klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def self.name "#{Relation.name}[#{Inflecto.camelize(name)}]" end def self.inspect name end def self.to_s name end def name #{name.inspect} end RUBY klass.send(:include, mod) yield(klass) klass.new(schema_relation.dataset, schema_relation.header) end end end
Version data entries
5 entries across 5 versions & 1 rubygems