Sha256: 9d6bbe42fa62ee2c5aba659cac742df4086ab9bb2dad31a481a22c8573c2c215

Contents?: true

Size: 470 Bytes

Versions: 4

Compression:

Stored size: 470 Bytes

Contents

module Rico
  class Resolver
    def self.to_proc
      @to_proc ||= lambda do |robject|
        klasses = robject.siblings.map{|s| s.data && s.data["_type"] }.compact.uniq
        return nil unless klasses.length == 1

        klass_name = Rico::TYPES.invert[klasses.first]
        return nil unless klass_name

        klass = Rico.const_get(klass_name)
        return nil unless klass.respond_to?(:resolve)

        klass.resolve(robject)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rico-0.5.0 lib/rico/resolver.rb
rico-0.4.0 lib/rico/resolver.rb
rico-0.3.0 lib/rico/resolver.rb
rico-0.2.0 lib/rico/resolver.rb