Class: Finitio::ProxyType
- Defined in:
- lib/finitio/type/proxy_type.rb,
lib/finitio/json_schema/proxy_type.rb
Constant Summary
Constants included from Metadata
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#target_name ⇒ Object
readonly
Returns the value of attribute target_name.
Instance Method Summary collapse
- #default_name ⇒ Object
-
#initialize(target_name, target = nil) ⇒ ProxyType
constructor
A new instance of ProxyType.
- #resolve_proxies(system) ⇒ Object
- #to_json_schema(*args, &bl) ⇒ Object
- #unconstrained ⇒ Object
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, 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
#target ⇒ Object (readonly)
Returns the value of attribute target.
12 13 14 |
# File 'lib/finitio/type/proxy_type.rb', line 12 def target @target end |
#target_name ⇒ Object (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
#default_name ⇒ Object
14 15 16 |
# File 'lib/finitio/type/proxy_type.rb', line 14 def default_name "_#{target_name}_" end |
#resolve_proxies(system) ⇒ Object
18 19 20 21 22 |
# File 'lib/finitio/type/proxy_type.rb', line 18 def resolve_proxies(system) system.fetch(target_name){ raise Error, "No such type `#{target_name}` in #{system}" } end |
#to_json_schema(*args, &bl) ⇒ Object
4 5 6 |
# File 'lib/finitio/json_schema/proxy_type.rb', line 4 def to_json_schema(*args, &bl) @target.to_json_schema(*args, &bl) if @target end |
#unconstrained ⇒ Object
24 25 26 27 |
# File 'lib/finitio/type/proxy_type.rb', line 24 def unconstrained return @target.unconstrained if @target raise Error, "`unconstrained` cannot be call whithout proxies being resolved" end |