Sha256: e987e5940d3ed98ef1647d2ede1d77bd037fe3164f72c83d0a7ff3391c7e6413
Contents?: true
Size: 716 Bytes
Versions: 1
Compression:
Stored size: 716 Bytes
Contents
# frozen_string_literal: true module Xa # A proxy class to store data from DSL class SubclassProxy def initialize(klass) @klass = klass end # Declare subclasses require certain conditions def require(conditions) TracePoint.trace :end do |tp| klass = tp.self next unless target?(klass) method_names = Array(conditions[:method]) unless method_names.all? { |name| klass.instance_methods.include?(name) } raise Xa::Error, "#{klass.name} is required to implement #{method_names.join(", ")}" end end end private def target?(klass) klass.name != @klass.name && klass.ancestors.include?(@klass) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xa-0.1.0 | lib/xa/subclass_proxy.rb |