Class: Finitio::ProxyType

Inherits:
Type
  • Object
show all
Defined in:
lib/finitio/type/proxy_type.rb

Constant Summary

Constants included from Metadata

Metadata::EMPTY_METADATA

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#==, #anonymous?, #default_name, #dress, #include?, #name, #name=, #named?, #to_s

Methods included from Metadata

#metadata, #metadata=, #metadata?

Constructor Details

#initialize(target_name, target = nil) ⇒ ProxyType

Returns a new instance of ProxyType.



4
5
6
7
8
9
10
11
# File 'lib/finitio/type/proxy_type.rb', line 4

def initialize(target_name, target = nil)
  unless target_name.is_a?(String)
    raise ArgumentError, "String expected for type name, got `#{target_name}`"
  end

  @target_name = target_name
  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



12
13
14
# File 'lib/finitio/type/proxy_type.rb', line 12

def target
  @target
end

#target_nameObject (readonly)

Returns the value of attribute target_name.



12
13
14
# File 'lib/finitio/type/proxy_type.rb', line 12

def target_name
  @target_name
end

Instance Method Details

#resolve(system) ⇒ Object



33
34
35
36
37
# File 'lib/finitio/type/proxy_type.rb', line 33

def resolve(system)
  @target = system.fetch(target_name) do
    raise Error, "No such type `#{target_name}`"
  end
end