Sha256: 4d8fc7e5d35659e640ab935b56721dd355c159d6b38a9b32b2681855584ac75a

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module Lutaml
  module XMI
    class GeneralizationAttributeDrop < Liquid::Drop
      def initialize(attr, upper_klass, gen_name, guidance = nil) # rubocop:disable Lint/MissingSuper,Metrics/ParameterLists,Layout/LineLength
        @attr = attr
        @upper_klass = upper_klass
        @gen_name = gen_name
        @guidance = guidance
      end

      def id
        @attr[:id]
      end

      def name
        @attr[:name]
      end

      def type
        @attr[:type]
      end

      def xmi_id
        @attr[:xmi_id]
      end

      def is_derived # rubocop:disable Naming/PredicateName
        @attr[:is_derived]
      end

      def cardinality
        ::Lutaml::XMI::CardinalityDrop.new(@attr[:cardinality])
      end

      def definition
        @attr[:definition]
      end

      def association
        @attr[:association]
      end

      def has_association?
        !!@attr[:association]
      end

      def type_ns
        @attr[:type_ns]
      end

      def upper_klass
        @upper_klass
      end

      def gen_name
        @gen_name
      end

      def name_ns
        @attr[:name_ns]
      end

      def used?
        if @guidance
          col_name = "#{name_ns}:#{name}"
          attr = @guidance["attributes"].find { |a| a["name"] == col_name }
          return attr["used"] if attr
        end

        true
      end

      def guidance
        if @guidance
          col_name = "#{name_ns}:#{name}"
          attr = @guidance["attributes"].find { |a| a["name"] == col_name }

          attr["guidance"] if attr
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lutaml-0.9.25 lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb
lutaml-0.9.24 lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb
lutaml-0.9.23 lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb
lutaml-0.9.22 lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb
lutaml-0.9.21 lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb
lutaml-0.9.20 lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb