Module: Clojure::Metadata
Instance Method Summary collapse
Instance Method Details
#metadata ⇒ Object
18 19 20 |
# File 'lib/clj/types.rb', line 18 def @metadata ||= Clojure::Map.new end |
#metadata=(value) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/clj/types.rb', line 22 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
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/clj/types.rb', line 31 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 |