class Faraday::Request::ReadOnly
Constants
- ALLOWED_REQUESTS
Public Class Methods
new(app)
click to toggle source
# File lib/yao/faraday_middlewares.rb, line 35 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# 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
Private Instance Methods
allowed_request?(env)
click to toggle source
# File lib/yao/faraday_middlewares.rb, line 57 def allowed_request?(env) return true if env[:method] == :get ALLOWED_REQUESTS.any? do |allowed| env[:method] == allowed[:method] && env[:url].path == allowed[:path] end end