Sha256: 822b002d5791fa6cb1f4754a2c715fc15f122a6e70c01509d082b1eb899ddd49
Contents?: true
Size: 862 Bytes
Versions: 50
Compression:
Stored size: 862 Bytes
Contents
module Arrest class ChildCollection #< BasicObject def initialize parent, clazz_name @parent = parent @clazz_name = clazz_name @children = nil end def build attributes = {} resolved_class.new(@parent.context, @parent, attributes) end def method_missing(*args, &block) if resolved_class.respond_to?(args[0]) sub_args = [@parent] sub_args += args.drop(1) resolved_class.send(args[0], *sub_args) else children.send(*args, &block) end end def inspect children.inspect end private def children if @children == nil @children = resolved_class.all_for(@parent) end @children end def resolved_class if @clazz == nil @clazz = Source.mod.const_get(@clazz_name) end @clazz end end end
Version data entries
50 entries across 50 versions & 1 rubygems