Class: Teamocil::ClosedStruct

Inherits:
Struct
  • Object
show all
Defined in:
lib/teamocil/utils/closed_struct.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ClosedStruct

Returns a new instance of ClosedStruct.



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/teamocil/utils/closed_struct.rb', line 3

def initialize(*args)
  args = [{}] unless args.any?

  args.first.each_pair do |key, value|
    # Make sure we only set values to defined arguments
    if members.map(&:intern).include?(key.to_sym)
      send "#{key}=", value
    else
      raise ArgumentError, "#{self.class.name} doesn’t support the `#{key}` keyword, only #{members.join(', ')}"
    end
  end
end