Class: Obk

Inherits:
Object
  • Object
show all
Defined in:
lib/obk.rb

Overview

Obk is a decorator that adds delays between object method calls.

For more information read README file.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2021 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(origin, pause: 1000) ⇒ Obk

Returns a new instance of Obk.



34
35
36
37
# File 'lib/obk.rb', line 34

def initialize(origin, pause: 1000)
  @origin = origin
  @pause = pause
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/obk.rb', line 39

def method_missing(*args)
  if block_given?
    @origin.__send__(*args) do |*a|
      yield(*a)
    end
  else
    @origin.__send__(*args)
  end
end

Instance Method Details

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/obk.rb', line 49

def respond_to?(method, include_private = false)
  @origin.respond_to?(method, include_private)
end

#respond_to_missing?(_method, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/obk.rb', line 53

def respond_to_missing?(_method, _include_private = false)
  true
end