Sha256: c2dcef23d852319d74de85449892931d0534e61cb36b479eced6c52d93731fd6
Contents?: true
Size: 701 Bytes
Versions: 1
Compression:
Stored size: 701 Bytes
Contents
# frozen_string_literal: true module BulkLoader class Attribute def initialize(cattr, target) @class_attribute = cattr @target = target @lazy_of ||= {} end def lazy(name) @lazy_of[name] ||= BulkLoader::Lazy.new(@target) end private def method_missing(name, *args) return super unless @class_attribute.include?(name) define_singleton_method(name) do attr = lazy(name) @class_attribute.load([name], [self]) unless attr.loaded? attr.get end public_send(name) end def respond_to_missing?(name, include_private) return true if @class_attribute.include?(name) super end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bulk_loader-0.1.0 | lib/bulk_loader/attribute.rb |