Class: Shep::OnDemandTypeBox
Overview
Abstract base class for TypeBox subinstances that hold Entities (e.g. the Entity::Account field in a Status).
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from TypeBox
#==, #get, #get_for_json, #initialize, #inspect, #set, #set?, #set_from_json, #to_s, to_yard_s, #unset?
Constructor Details
This class inherits a constructor from Shep::TypeBox
Class Method Details
.wrapping(type) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/shep/typeboxes.rb', line 108 def self.wrapping(type) @subklasses ||= {} tid = type.__id__ # we use __id__ to ensure we're hashing by identity unless @subklasses.has_key?(tid) klassname = "#{self}[#{type}]" sk = Class.new(self) sk.define_singleton_method(:element_klass) { return type } sk.define_singleton_method(:to_s) { return klassname } sk.define_singleton_method(:inspect) { return klassname } @subklasses[tid] = sk end return @subklasses[tid] end |
Instance Method Details
#element_klass ⇒ Object
104 |
# File 'lib/shep/typeboxes.rb', line 104 def element_klass() raise Error.new("Used base class!") ; end |