lib/oscal/value.rb in oscal-0.1.1 vs lib/oscal/value.rb in oscal-0.2.0

- old
+ new

@@ -4,10 +4,11 @@ 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 @@ -15,16 +16,16 @@ obj.map do |x| Value.wrap(x) end end - def initialize(options={}) + def initialize(options = {}) unless options.is_a? Hash - options = {'val' => options} + options = { "val" => options } end - options.each_pair.each do |key,val| - key_name = key.gsub('-','_') + 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