Class: Minitext::AllowlistProxy
- Inherits:
-
Object
- Object
- Minitext::AllowlistProxy
- Defined in:
- lib/minitext/allowlist_proxy.rb
Instance Attribute Summary collapse
-
#allowed ⇒ Object
readonly
Returns the value of attribute allowed.
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
Instance Method Summary collapse
- #deliver(message) ⇒ Object
-
#initialize(allowed:, gateway: nil) ⇒ AllowlistProxy
constructor
A new instance of AllowlistProxy.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to_missing?(method, *args) ⇒ Boolean
Constructor Details
#initialize(allowed:, gateway: nil) ⇒ AllowlistProxy
Returns a new instance of AllowlistProxy.
7 8 9 10 |
# File 'lib/minitext/allowlist_proxy.rb', line 7 def initialize(allowed:, gateway: nil) @allowed = Set.new(allowed) @gateway = gateway || TestGateway.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
16 17 18 |
# File 'lib/minitext/allowlist_proxy.rb', line 16 def method_missing(method, *args, &block) gateway.send(method, *args, &block) end |
Instance Attribute Details
#allowed ⇒ Object (readonly)
Returns the value of attribute allowed.
5 6 7 |
# File 'lib/minitext/allowlist_proxy.rb', line 5 def allowed @allowed end |
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
5 6 7 |
# File 'lib/minitext/allowlist_proxy.rb', line 5 def gateway @gateway end |
Instance Method Details
#deliver(message) ⇒ Object
12 13 14 |
# File 'lib/minitext/allowlist_proxy.rb', line 12 def deliver() gateway.deliver() if allowed?(.to) end |
#respond_to_missing?(method, *args) ⇒ Boolean
20 21 22 |
# File 'lib/minitext/allowlist_proxy.rb', line 20 def respond_to_missing?(method, *args) gateway.respond_to?(method) end |