Sha256: abd9f273937d464781fb866bc80c8b7717594c71e58032cb6c8f0ef3fc2602a9
Contents?: true
Size: 981 Bytes
Versions: 4
Compression:
Stored size: 981 Bytes
Contents
require 'mspire/cv/param' module Mspire module CV module Paramable attr_accessor :params def initialize(opts={params: []}) describe!(*opts[:params]) end # casts each string or array as a Param object (using Mspire::CV::Param[]), # pushes it onto the params attribute and returns the growing params object def describe!(*args) @params ||= [] as_params = args.map do |arg| if arg.is_a?(Array) Mspire::CV::Param[ *arg ] elsif arg.is_a?(String) Mspire::CV::Param[ arg ] else arg end end @params.push(*as_params) end # if params respond_to?(:to_xml) then will call that, otherwise # iterates over @params and calls .to_xml on each object. def to_xml(xml) if @params @params.each do |el| el.to_xml(xml) end end xml end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mspire-0.7.5 | lib/mspire/cv/paramable.rb |
mspire-0.7.4 | lib/mspire/cv/paramable.rb |
mspire-0.7.3 | lib/mspire/cv/paramable.rb |
mspire-0.7.2 | lib/mspire/cv/paramable.rb |