Sha256: 25b46e57a7a43d50a0d02a41d0702b3598a67740a0c4f9cb582a2fc1e1c13614

Contents?: true

Size: 562 Bytes

Versions: 11

Compression:

Stored size: 562 Bytes

Contents

module EDN
  module Metadata
    def self.extended(base)
      base.instance_eval do
        alias :to_edn_without_metadata :to_edn
        alias :to_edn :to_edn_with_metadata
      end
    end

    attr_accessor :metadata

    def has_metadata?
      respond_to?(:allows_metadata?) and
        allows_metadata? and
        !metadata.nil? and
        !metadata.empty?
    end

    def to_edn_with_metadata
      if has_metadata?
        '^' + metadata.to_edn + ' ' + to_edn_without_metadata
      else
        to_edn_without_metadata
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
edn2023-1.1.4 lib/edn/metadata.rb
edn-1.1.1 lib/edn/metadata.rb
edn-1.1.0 lib/edn/metadata.rb
edn-1.0.8 lib/edn/metadata.rb
edn-1.0.7 lib/edn/metadata.rb
edn-1.0.6 lib/edn/metadata.rb
edn-1.0.5 lib/edn/metadata.rb
edn-1.0.3 lib/edn/metadata.rb
edn-1.0.2 lib/edn/metadata.rb
edn-1.0.1 lib/edn/metadata.rb
edn-1.0.0 lib/edn/metadata.rb