Sha256: e8dc888c71e600fd55fba46837b934bc7fa2ce15ac65649f8158408740b735c6

Contents?: true

Size: 551 Bytes

Versions: 36

Compression:

Stored size: 551 Bytes

Contents

module Schemacop::V2
  class NodeResolver
    class_attribute :node_classes
    self.node_classes = [].freeze

    def self.register(node_class, before: nil)
      if before
        unless (index = node_classes.find_index(before))
          fail "Cannot insert before class #{before} which has not been registered yet."
        end

        node_classes.insert(index, node_class)
      else
        self.node_classes += [node_class]
      end
    end

    def self.resolve(type)
      node_classes.find { |c| c.type_matches?(type) }
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
schemacop-3.0.29 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.28 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.27 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.26 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.25 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.24 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.23 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.22 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.21 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.20 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.19 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.18 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.17 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.16 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.15 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.14 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.13 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.12 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.11 lib/schemacop/v2/node_resolver.rb
schemacop-3.0.10 lib/schemacop/v2/node_resolver.rb