Class: Finitio::AliasType

Inherits:
Type
  • Object
show all
Defined in:
lib/finitio/type/alias_type.rb,
lib/finitio/generation/alias_type.rb,
lib/finitio/json_schema/alias_type.rb

Constant Summary

Constants included from Metadata

Metadata::EMPTY_METADATA

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

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

Methods included from Metadata

#metadata, #metadata=, #metadata?

Constructor Details

#initialize(target, name, metadata = nil) ⇒ AliasType

Returns a new instance of AliasType.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/finitio/type/alias_type.rb', line 4

def initialize(target, name,  = nil)
  unless target.is_a?(Type)
    raise ArgumentError, "Type expected for target type, got `#{target}`"
  end
  if name.nil?
    raise ArgumentError, "Alias name cannot be nil"
  end

  super(name, )
  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



15
16
17
# File 'lib/finitio/type/alias_type.rb', line 15

def target
  @target
end

Instance Method Details

#default_nameObject



17
18
19
# File 'lib/finitio/type/alias_type.rb', line 17

def default_name
  @name
end

#generate_data(generator, world = nil) ⇒ Object



4
5
6
# File 'lib/finitio/generation/alias_type.rb', line 4

def generate_data(generator, world = nil)
  generator.call(target, world)
end

#resolve_proxies(system) ⇒ Object



36
37
38
# File 'lib/finitio/type/alias_type.rb', line 36

def resolve_proxies(system)
  AliasType.new(target.resolve_proxies(system), name, )
end

#to_json_schema(*args, &bl) ⇒ Object



4
5
6
# File 'lib/finitio/json_schema/alias_type.rb', line 4

def to_json_schema(*args, &bl)
  target.to_json_schema(*args, &bl)
end

#unconstrainedObject



40
41
42
# File 'lib/finitio/type/alias_type.rb', line 40

def unconstrained
  AliasType.new(target.unconstrained, name, )
end