module EDN::Metadata

Attributes

metadata[RW]

Public Class Methods

extended(base) click to toggle source
# File lib/edn/metadata.rb, line 3
def self.extended(base)
  base.instance_eval do
    alias :to_edn_without_metadata :to_edn
    alias :to_edn :to_edn_with_metadata
  end
end

Public Instance Methods

has_metadata?() click to toggle source
# File lib/edn/metadata.rb, line 12
def has_metadata?
  respond_to?(:allows_metadata?) and
    allows_metadata? and
    !metadata.nil? and
    !metadata.empty?
end
to_edn_with_metadata() click to toggle source
# File lib/edn/metadata.rb, line 19
def to_edn_with_metadata
  if has_metadata?
    '^' + metadata.to_edn + ' ' + to_edn_without_metadata
  else
    to_edn_without_metadata
  end
end