Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Client
- class ClientException < Exception; end
- class Entity
- def foo(bar)
- raise ClientException unless bar
- "original #{bar}"
- end
- end
- end
- module ImprovedClient
- class Entity < Client::Entity
- def foo(bar)
- return unless bar
- original = super bar
- "decorated #{original}"
- rescue ClientException
- nil
- end
- end
- end
- # usage
- entity = ImprovedClient::Entity.new
- entity.foo 'baz' # => "decorated original baz"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement