Class: Faraday::Request::ReadOnly

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ReadOnly

Returns a new instance of ReadOnly.



35
36
37
# File 'lib/yao/faraday_middlewares.rb', line 35

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/yao/faraday_middlewares.rb', line 39

def call(env)
  return @app.call(env) if allowed_request?(env)

  if Yao.config.raise_on_write
    raise Yao::ReadOnlyViolationError
  elsif Yao.config.noop_on_write
    env
  else
    @app.call(env)
  end
end