Sha256: fb35dc0c1fee6f724c38dec00fc30431ccc30b739b260dc9ae99b319cf23ac1a

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Declarative
  def self.Inspect(obj)
    string = obj.inspect

    if obj.is_a?(Proc)
      elements = string.split('/')
      string = "#{elements.first}#{elements.last}"
    end
    string.gsub(/0x\w+/, '')
  end

  module Inspect
    def inspect
      string = super
      if is_a?(Proc)
        elements = string.split('/')
        string = "#{elements.first}#{elements.last}"
      end
      string.gsub(/0x\w+/, '')
    end

    module Schema
      def inspect
        definitions.extend(Definitions::Inspect)
        "Schema: #{definitions.inspect}"
      end
    end
  end

  module Definitions::Inspect
    def inspect
      each do |dfn|
        dfn.extend(Declarative::Inspect)

        if dfn[:nested]&.is_a?(Declarative::Schema::DSL)
          dfn[:nested].extend(Declarative::Inspect::Schema)
        else
          dfn[:nested]&.extend(Declarative::Definitions::Inspect)
        end
      end
      super
    end

    def get(*)
      super.extend(Declarative::Inspect)
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/declarative-0.0.20/lib/declarative/testing.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/declarative-0.0.20/lib/declarative/testing.rb
declarative-0.0.20 lib/declarative/testing.rb