Class: EvalIn::Mock
- Inherits:
-
Object
- Object
- EvalIn::Mock
- Defined in:
- lib/eval_in/mock.rb
Instance Method Summary collapse
- #call(code, options = {}) ⇒ Object
- #fetch_result(raw_url, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
9 10 11 12 13 14 |
# File 'lib/eval_in/mock.rb', line 9 def initialize(={}) @result = .fetch :result, nil @languages = .fetch :languages, Hash.new @on_call = .fetch(:on_call) { lambda { |*args| @result || evaluate_with_tempfile(*args) } } @on_fetch_result = .fetch(:on_fetch_result) { lambda { |*args| @result || EvalIn.fetch_result(*args) } } end |
Instance Method Details
#call(code, options = {}) ⇒ Object
16 17 18 19 |
# File 'lib/eval_in/mock.rb', line 16 def call(code, ={}) language_name = EvalIn::Client.language_or_error_from @on_call.call(code, ) end |
#fetch_result(raw_url, options = {}) ⇒ Object
21 22 23 |
# File 'lib/eval_in/mock.rb', line 21 def fetch_result(raw_url, ={}) @on_fetch_result.call(raw_url, ) end |