Sha256: dae9672fc7ce40e26b16562b62d12a69f096ebaf3f7d0b74fff6ad9c53685d2a

Contents?: true

Size: 790 Bytes

Versions: 135

Compression:

Stored size: 790 Bytes

Contents

require "expressir/express/named_type"

module Expressir
  module Express
    class DefinedType < NamedType
      def initialize(options = {})
        @options = options
        @schema = options.fetch(:schema)
      end

      def parse
        document = @options.fetch(:document)
        extract_type_attributes(document)

        self
      end

      def self.parse(document, schema)
        new(document: document, schema: schema).parse
      end

      private

      def extract_type_attributes(document)
        @name = document.attributes["name"].to_s
        @wheres = extract_where_rules(document)
      end

      def extract_where_rules(document)
        document.xpath("where").map do |where|
          Express::WhereRule.parse(where)
        end
      end
    end
  end
end

Version data entries

135 entries across 135 versions & 1 rubygems

Version Path
expressir-0.2.10-x86_64-darwin lib/expressir/express/defined_type.rb
expressir-0.2.10-x86-mingw32 lib/expressir/express/defined_type.rb
expressir-0.2.10-x86-linux lib/expressir/express/defined_type.rb
expressir-0.2.10-x64-mingw32 lib/expressir/express/defined_type.rb
expressir-0.2.10-arm64-darwin lib/expressir/express/defined_type.rb
expressir-0.2.9 lib/expressir/express/defined_type.rb
expressir-0.2.9-x86_64-linux lib/expressir/express/defined_type.rb
expressir-0.2.9-x86_64-darwin lib/expressir/express/defined_type.rb
expressir-0.2.9-x86-mingw32 lib/expressir/express/defined_type.rb
expressir-0.2.9-x86-linux lib/expressir/express/defined_type.rb
expressir-0.2.9-x64-mingw32 lib/expressir/express/defined_type.rb
expressir-0.2.9-arm64-darwin lib/expressir/express/defined_type.rb
expressir-0.2.8 lib/expressir/express/defined_type.rb
expressir-0.2.8-x86_64-linux lib/expressir/express/defined_type.rb
expressir-0.2.8-x86_64-darwin lib/expressir/express/defined_type.rb
expressir-0.2.8-x86-mingw32 lib/expressir/express/defined_type.rb
expressir-0.2.8-x86-linux lib/expressir/express/defined_type.rb
expressir-0.2.8-x64-mingw32 lib/expressir/express/defined_type.rb
expressir-0.2.8-arm64-darwin lib/expressir/express/defined_type.rb
expressir-0.2.7 lib/expressir/express/defined_type.rb