Sha256: cbc26315d3b32519aa75bab970481acf9113b0867bc626c64c782edd0a7ec8da

Contents?: true

Size: 787 Bytes

Versions: 3

Compression:

Stored size: 787 Bytes

Contents

require "expressir/express/model_element"

module Expressir
  module Express
    class UniqueRule < ModelElement
      attr_accessor :name, :attributes

      def initialize(options)
        @name = nil
        @attributes = []
        @options = options
      end

      def parse
        document = @options.fetch(:document, nil)
        extract_unique_attributes(document)

        self
      end

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

      private

      def extract_unique_attributes(document)
        @name = document.attributes["label"].to_s
        @attributes = document.xpath("unique.attribute").map do |attribute|
          attribute.attributes["attribute"]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
expressir-0.2.6 lib/expressir/express/unique_rule.rb
expressir-0.2.5-x64-mingw32 lib/expressir/express/unique_rule.rb
expressir-0.2.4-x64-mingw32 lib/expressir/express/unique_rule.rb