Sha256: 70708097bbd0865f6da741e25a3544884761c834fc4d86d13e1bf3a951018a7a

Contents?: true

Size: 832 Bytes

Versions: 8

Compression:

Stored size: 832 Bytes

Contents

module Declarative
  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 { |dfn|
        dfn.extend(Declarative::Inspect)

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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
declarative-0.0.9 lib/declarative/testing.rb
declarative-0.0.8 lib/declarative/testing.rb
declarative-0.0.7 lib/declarative/testing.rb
declarative-0.0.6 lib/declarative/testing.rb
declarative-0.0.5 lib/declarative/testing.rb
declarative-0.0.4 lib/declarative/testing.rb
declarative-0.0.3 lib/declarative/testing.rb
declarative-0.0.2 lib/declarative/testing.rb