Class: Module::CompositeType

Inherits:
Module
  • Object
show all
Defined in:
lib/composite_type.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

CACHE =
{ }
CACHE_MUTEX =
Mutex.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Module

#&, #of, #with, #|, #~@

Constructor Details

#initialize(types) ⇒ CompositeType

Returns a new instance of CompositeType.

Raises:



17
18
19
20
# File 'lib/composite_type.rb', line 17

def initialize types
  raise Error, "cannot create CompositeType from unamed object" unless types.all?{|x| x.name}
  @_t = types
end

Instance Attribute Details

#_tObject (readonly)

Returns the value of attribute _t.



21
22
23
# File 'lib/composite_type.rb', line 21

def _t
  @_t
end

Class Method Details

.new_cached(*types) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/composite_type.rb', line 7

def self.new_cached *types
  key = [ self, types ]
  (Thread.current[:'Module::CompositeType.cache'] ||= { })[key] ||=
  CACHE_MUTEX.synchronize do
    CACHE[key] ||= new(types)
  end
end

Instance Method Details

#nameObject



22
# File 'lib/composite_type.rb', line 22

def name; to_s; end