Method: Invoiced::Object#method_missing

Defined in:
lib/invoiced/object.rb

#method_missing(name, *args) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/invoiced/object.rb', line 149

def method_missing(name, *args)
    if name.to_s.end_with?('=')
        attr = name.to_s[0...-1].to_sym
        add_accessors([attr])
        begin
            mth = method(name)
        rescue NameError
            raise NoMethodError.new("Cannot set #{attr} on this object. HINT: you can't set: #{@@permanent_attributes.to_a.join(', ')}")
        end
        return mth.call(args[0])
    else
        return @values[name] if @values.has_key?(name)
    end

    begin
        super
    rescue NoMethodError => e
        raise e
    end
end