Sha256: c7e19d3de20a65efa466eda4b4735ef69e6e6db34de6d47828742a9f68f9da39
Contents?: true
Size: 1.87 KB
Versions: 8
Compression:
Stored size: 1.87 KB
Contents
require "builder" module Reactor module Cm class XmlMarkup < Builder::XmlMarkup def where_key_tag!(base_name, key, value) where_tag!(base_name) do |xml| xml.tag!(key.to_s) do xml.text!(value.to_s) end end end def where_tag!(base_name) tag!("#{base_name}-where") do |xml| yield xml end end def create_tag!(base_name) tag!("#{base_name}-create") do |xml| yield xml end end def delete_tag!(base_name) tag!("#{base_name}-delete") end def get_key_tag!(base_name, key) get_tag!(base_name) do |xml| if key.is_a?(::Array) key.each { |k| xml.tag!(k.to_s) } else xml.tag!(key.to_s); end end end def get_tag!(base_name) tag!("#{base_name}-get") do |xml| yield xml end end def set_key_tag!(base_name, key, value, options = {}) set_tag!(base_name) do value_tag!(key, value, options) end end def set_tag!(base_name) tag!("#{base_name}-set") do |xml| yield xml end end def value_tag!(key, value, options = {}) if value.is_a? ::Array then array_value_tag!(key, value, options) elsif value.is_a? ::Hash then hash_value_tag!(key, value) else tag!(key.to_s) { text!(value.to_s) } end end def array_value_tag!(name, values, options = {}) tag!(name.to_s, options) do values.each do |value| tag!("listitem") do text!(value.to_s) end end end end def hash_value_tag!(name, hash) hash.each do |value, attr_hash| tag!(name.to_s, attr_hash) do text!(value.to_s) end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems