Sha256: 558fd1b16f68f1dbc1c0c676b5b890e7099c6fef56ae6bd665a3095677d28b26

Contents?: true

Size: 732 Bytes

Versions: 7

Compression:

Stored size: 732 Bytes

Contents

module Finitio
  class ProxyType < Type

    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
    attr_reader :target_name, :target

    def default_name
      "_#{target_name}_"
    end

    def resolve_proxies(system)
      system.fetch(target_name){
        raise Error, "No such type `#{target_name}` in #{system}"
      }
    end

    def unconstrained
      return @target.unconstrained if @target
      raise Error, "`unconstrained` cannot be call whithout proxies being resolved"
    end

  end # class ProxyType
end # module Finitio

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
finitio-0.11.3 lib/finitio/type/proxy_type.rb
finitio-0.11.2 lib/finitio/type/proxy_type.rb
finitio-0.11.1 lib/finitio/type/proxy_type.rb
finitio-0.10.0 lib/finitio/type/proxy_type.rb
finitio-0.9.1 lib/finitio/type/proxy_type.rb
finitio-0.9.0 lib/finitio/type/proxy_type.rb
finitio-0.8.0 lib/finitio/type/proxy_type.rb