Sha256: 676ea947f3ac5674cbbe3ee85d47e5b6cdb788c7b118f04ddd7634c9880846b6
Contents?: true
Size: 679 Bytes
Versions: 6
Compression:
Stored size: 679 Bytes
Contents
# frozen_string_literal: true module SuperSettings # Interface to expose mass setting attributes on an object. Setting attributes with a # hash will simply call the attribute writers for each key in the hash. module Attributes class UnknownAttributeError < StandardError end def initialize(attributes = nil) self.attributes = attributes if attributes end def attributes=(values) values.each do |name, value| if respond_to?("#{name}=", true) send("#{name}=", value) else raise UnknownAttributeError.new("unknown attribute #{name.to_s.inspect} for #{self.class}") end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems