70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/erector/needs.rb', line 70
def initialize(assigns = {})
super
assigned = assigns.keys
self.class.needed_defaults.each do |name, value|
unless assigned.include?(name)
instance_variable_set("@#{name}", value)
assigned << name
end
end
missing = self.class.needed_variables - assigned
unless missing.empty? || missing == [nil]
raise "Missing parameter#{missing.size == 1 ? '' : 's'}: #{missing.join(', ')}"
end
excess = assigned - self.class.needed_variables
unless self.class.needed_variables.empty? || excess.empty?
raise("Excess parameter#{excess.size == 1 ? '' : 's'}: #{excess.join(', ')}")
end
end
|