Sha256: 890fb459634f1db2217168fb92528083755ac34a4efa615cb211a3b6925b70df
Contents?: true
Size: 741 Bytes
Versions: 3
Compression:
Stored size: 741 Bytes
Contents
require_relative "base_class" module Oscal class Value < Oscal::BaseClass include Serializer KEY = %i(val) attr_accessor *KEY attr_serializable *KEY def self.wrap(obj) return obj if obj.is_a? Value return Value.new(obj) unless obj.is_a? Array obj.map do |x| Value.wrap(x) end end def initialize(options = {}) unless options.is_a? Hash options = { "val" => options } end options.each_pair.each do |key, val| key_name = key.gsub("-", "_") unless KEY.include?(key_name.to_sym) raise UnknownAttributeError.new("Unknown key `#{key}` in Value") end self.send("#{key_name}=", val) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oscal-0.2.3 | lib/oscal/value.rb |
oscal-0.2.2 | lib/oscal/value.rb |
oscal-0.2.0 | lib/oscal/value.rb |