Method: Deplate::CommonObject.method_missing

Defined in:
lib/deplate/common.rb

.method_missing(method, *args) ⇒ Object



455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/deplate/common.rb', line 455

def method_missing(method, *args)
    # p "DBG method_missing: #{method} #{args}"
    class_attributes_ensure
    method_s = method.to_s
    if method_s =~ /=$/
        method_s = method_s[0..-2]
        method_y = method_s.intern
        setter   = true
    else
        method_y = method
        setter   = false
    end
    if @class_attributes.keys.include?(method_y)
        pre = "hook_pre_#{method}"
        if respond_to?(pre)
            send(pre, *args)
        end
        if setter
            if args.size > 1
                raise "Wrong number of arguments: #{method} #{args}"
            end
            rv = @class_attributes[method_y] = args[0]
        else
            rv = @class_attributes[method_y]
        end
        post = "hook_post_#{method}"
        if respond_to?(post)
            send(post, *args)
        end
        # p "DBG method_missing => #{rv}"
        return rv
    else
        super
    end
end