Class: Type::Definition::Proxy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/type/definition/proxy.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The Proxy is an in-progress definition, a convenience object to support the declaration syntax.

Instance Method Summary collapse

Constructor Details

#initialize(name, klass) ⇒ Proxy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Proxy.



9
10
11
12
# File 'lib/type/definition/proxy.rb', line 9

def initialize(name, klass)
  @name = name
  @klass = klass
end

Instance Method Details

#from(parent, &config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (ArgumentError)

See Also:

  • for usage


15
16
17
18
19
20
21
# File 'lib/type/definition/proxy.rb', line 15

def from(parent, &config)
  raise ArgumentError, 'Block Required!' unless block_given?

  Type[parent].tap do |resolved_parent|
    raise ArgumentError unless resolved_parent.kind_of?(@klass)
  end.refine(@name, &config)
end