Sha256: af1790f884e8367d0a790690e0323751c148eb6b40887c272aae3cd29826156a

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

module Expressir
  module Express
    class Inverse < Attribute
      attr_accessor :reverseAttr_id, :reverseAttr, :reverseEntity

      def initialize(options = {})
        @options = options
        @entity = options.fetch(:entity, nil)
      end

      def parse
        document = @options.fetch(:document)
        extract_common_attributes(document)
        extract_type_specific_attributes(document)

        self
      end

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

      private

      def extract_type_specific_attributes(document); end

      def extract_common_attributes(document)
        @name = document.attributes["name"].to_s
        @reverseAttr_id = document.attributes["attribute"]
        @domain = document.attributes["entity"].to_s

        extract_redeclaration_attributes(document)
      end

      def extract_redeclaration_attributes(document)
        redeclaration = document.xpath("redeclaration").first

        if redeclaration
          @redeclare_entity = redeclaration.attributes["entity-ref"].to_s
          old_name = redeclaration.attributes["old_name"]
          @redeclare_oldname = old_name.to_s if old_name
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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