Module: Clojure::Metadata
Instance Method Summary collapse
Instance Method Details
#metadata ⇒ Object
13 14 15 |
# File 'lib/clj/types.rb', line 13 def @metadata ||= Clojure::Map.new end |
#metadata=(value) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/clj/types.rb', line 17 def (value) .merge! case value when Hash then value when Symbol then { value => true } when String then { :tag => value } else raise ArgumentError, 'the passed value is not suitable as metadata' end end |
#metadata_to_clj(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/clj/types.rb', line 26 def ( = {}) return '' unless [:metadata] != false && @metadata && !@metadata.empty? '^' + if @metadata.length == 1 piece = @metadata.first if piece.first.is_a?(Symbol) && piece.last == true piece.first.to_clj() elsif piece.first == :tag && piece.last.is_a?(String) piece.last.to_clj() else @metadata.to_clj() end else @metadata.to_clj() end + ' ' end |