Sha256: e470c0a0131a7950b7108933c40d9e9f64b8d459823061183be585c62b54cdb2

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

module Oscal
  class Parameter

    KEY = %i(id label select)
    attr_accessor *KEY

    def self.wrap(obj)
      return obj if obj.is_a? Parameter
      return Parameter.new(obj) unless obj.is_a? Array

      obj.map do |x|
        Parameter.wrap(x)
      end
    end

    def initialize(options={})
      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 Parameter")
        end

        self.send("#{key_name}=", val)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oscal-0.1.0 lib/oscal/parameter.rb