Class: NRB::BreweryControlSystem::API::VersionCheck
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- NRB::BreweryControlSystem::API::VersionCheck
- Extended by:
- Middleware::Registration
- Includes:
- ServerVersion
- Defined in:
- lib/brewery_control_system/api/version_check.rb
Instance Attribute Summary collapse
-
#required_version ⇒ Object
readonly
Returns the value of attribute required_version.
Instance Method Summary collapse
-
#initialize(app = nil, version = nil) ⇒ VersionCheck
constructor
A new instance of VersionCheck.
- #on_complete(env) ⇒ Object
Methods included from Middleware::Registration
Methods included from ServerVersion
Constructor Details
#initialize(app = nil, version = nil) ⇒ VersionCheck
Returns a new instance of VersionCheck.
9 10 11 12 13 |
# File 'lib/brewery_control_system/api/version_check.rb', line 9 def initialize(app=nil,version=nil) raise ArgumentError.new("Must supply an api version to compare against") if version.nil? super app @required_version = version end |
Instance Attribute Details
#required_version ⇒ Object (readonly)
Returns the value of attribute required_version.
7 8 9 |
# File 'lib/brewery_control_system/api/version_check.rb', line 7 def required_version @required_version end |
Instance Method Details
#on_complete(env) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/brewery_control_system/api/version_check.rb', line 16 def on_complete(env) remote_version = server_version env[:response_headers] if remote_version != required_version warn "BCS Firmware version (#{remote_version}) does not match API version (#{required_version})." end end |